Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phonegap 3.0 compatibility? Project status? #1

Closed
damrbaby opened this issue Jul 29, 2013 · 25 comments
Closed

Phonegap 3.0 compatibility? Project status? #1

damrbaby opened this issue Jul 29, 2013 · 25 comments

Comments

@damrbaby
Copy link

Hello!

Just curious about this project status given the warning in the readme:

WARNING: I'M CURRENLTY REWRITING PART OF THIS PLUGING. IT'S NOT YET USABLE!

Now that cordova 3.0 is out it's unclear whether this will work or not, or whether it is still in active development.

@j3k0
Copy link
Owner

j3k0 commented Jul 30, 2013

Hello!

Yes, I'm just done working on a project using it. It's on the store and it works, so the plugin is certainly safe to use.

I didn't try on Cordova 3.0 yet however, I use PhoneGap 2.7.0.

@mlegenhausen
Copy link

It seems PhoneGap 3.0 ios project has ARC enabled as default. When compiling this code it is not working.

@jkirkell
Copy link
Contributor

I am using the plugin with Cordova 3.0x and it works for the most part. The main issue is that the config.xml needs to be updated to change the plugin tag to be a feature tag.

@guiix-code
Copy link

I second the issue of ARC problems. There are several uses of the release function, e.g. [numberFormatter release];, that are not permitted.

@damrbaby
Copy link
Author

FYI you can get around ARC restrictions by following these instructions for InAppPurchase.m and SKProduct+LocalizedPrice.m

Also for PhoneGap >= 3.0 this plugin can be installed with a single command:

cordova plugin add git://github.com/j3k0/PhoneGap-InAppPurchase-iOS.git

@areoburn
Copy link

I setup the plugin through the cordova plugin command on Phonegap 3.0

I made sure the xml file has the feature tags and everything is in the right places.

I have been trying to get the plugin to work but for some reason storekit isn't being recognized from the beginning. I am running it inside the device ready function.

Can someone please look into this? I've been bashing my head on this for hours and couldn't get it to work.

@jkirkell
Copy link
Contributor

take a look at https://github.com/jkirkell/cordova-inapp-sample which is just the steps to follow for setting up using InApp purchasing plugins. The code is for reference only and should not be run since I excluded the binaries.

@areoburn
Copy link

jkirkell thank you very much for the fast reply! I checked my project and everything is setup perfectly. I am sorry I miss worded my problem. I found the exact problem.

When I do:
storekit.load(['inapp1', 'inapp2'], function (products, invalidIds) {});

The callback function does not run.

InAppPurchase[objc]: Getting products data
InAppPurchase[objc]: Set has 2 elements
InAppPurchase[objc]: - inapp1
InAppPurchase[objc]: - inapp2
InAppPurchase[objc]: start

That's about all I receive. I tried setting alerts and a variety of other tests inside the callback, but nothing seems to work.

It would be of great help if someone can help figure this out because I noticed many people were experiencing this problem on the guide page as well.

@guiix-code
Copy link

If you know a little Objective-C, when you compile and come up with errors, you can go through the list and click on each to highlight the problem lines, then you can comment out (add "//" to the beginning of the line) any line that just has release on it. There's one line that has some other initialisation too, where you would just remove the "release" part, and not the rest.

@jkirkell
Copy link
Contributor

@areoburn I now see what you are seeing, but only when I compile and push to IOS7 in the simulator. IOS6.1 still works fine. I am looking at it and will report back later today.

@jkirkell
Copy link
Contributor

The super quick answer is that the code works fine when using the simulator for IOS6.1 only. IOS7 and IOS7 64bit both are croaking with the storekit initialization. I will keep working on it.

@damrbaby
Copy link
Author

I thought you can't test storekit in the simulator? I wouldn't expect it to work in the simulator at all.

@jkirkell
Copy link
Contributor

For anyone looking, Apple is not letting the simulator to run in-app purchases per their notes https://developer.apple.com/library/ios/releasenotes/DeveloperTools/RN-Xcode/index.html.

StoreKit (In-App purchases) will not work in the Simulator. 13962338

I have tested the current code on a device running IOS7 (iPhone5) and sandbox in-app purchasing works.

@areoburn
Copy link

Thank you jkirkell! I finally can continue working on my app!

Has anyone experienced this problem with the callback function?

var IAP_loaded = false; // Global Scope
var IAP_onReady = function(){
storekit.load(IAP_list, function (products, invalidIds) {
console.log('IAP LOADING...');
IAP_products = products;
IAP_loaded = true;
console.log("1] -- IAP Loaded: "+IAP_loaded); // Outputs true
});
console.log("2] -- IAP Loaded: "+IAP_loaded); // Outputs false
IAP_loaded = true;
console.log("3] -- IAP Loaded: "+IAP_loaded); // Outputs true
};

console.log("4] -- IAP Loaded: "+IAP_loaded); // Outputs false

For some my global variables aren't staying modified outside the function itself...
I created a completely separate function and changed a global variable and it works fine. This just mind baffles me. Any thoughts?

@areoburn
Copy link

Never mind, I figured out storekit is being run as async and I came across a solution. Thanks again for the help

@areoburn
Copy link

Hey have any of you experienced the Error message "Cannot connect to itunes" after a successful purchase restore? I seem to keep getting this error, but the purchase is going through.

Not sure if this is a sandbox environment error or not

@jkirkell
Copy link
Contributor

Running in the simulator using a sandbox user on IOS6 or 6.1, I would see strange issues like

  • being forced to login twice when either buying or restoring
  • the cannot connect to iTunes message
  • the purchase and restore methods being executed multiple times

When I installed on a device and used the sandbox user, all that went away.

Hope that helps

@tiendq
Copy link

tiendq commented Oct 2, 2013

For short, both methods work well:

  1. Add -fno-objc-arc flag to files as instructed here: https://github.com/jkirkell/cordova-inapp-sample
  2. Comment code as @doomsy pointed out. I prefer this way, error message is clear, isn't it?

Thanks,

@guiix-code
Copy link

The error messages are clear, though I ran into one app crash during my usage. I'm not sure if it was related specifically to what I commented out, but I ended up switching to the "Add -fno-objc-arc flag" option to keep things simple.

@wootwoot1234
Copy link

@jkirkell and @areoburn did you guys ever figure out a fix for the storekit.load(['inapp1', 'inapp2'], function (products, invalidIds) {}); callback? It connects to apple's servers and prints the information in the console but never calls the callback. BTW, I'm running these tests on an iPhone 5 with iOS 7.

@jkirkell
Copy link
Contributor

jkirkell commented Oct 3, 2013

Apple disabled running storekit through the IOS Simulator. When you install
on the device and login using the test accounts, everything works fine.

What I ended up doing in my code was to add a flag to add the product as a
"fake" purchase so my app can be tested still in the simulator.

Hope that helps.
Jeff

On Thu, Oct 3, 2013 at 10:46 AM, wootwoot1234 notifications@github.comwrote:

@jkirkell https://github.com/jkirkell and @areoburnhttps://github.com/areoburndid you guys ever figure out a fix for the storekit.load(['inapp1',
'inapp2'], function (products, invalidIds) {}); callback? It connects to
apple's servers and prints the information in the console but never calls
the callback. BTW, I'm running these tests on an iPhone 5 with iOS 7.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-25626419
.

@wootwoot1234
Copy link

Hey Jeff. Thanks for the quick response. Good point. I always forget to login to my test account. I logged in and still the load callback isn't being called. I thought it might be a timing issue with the init function so I pulled the load function out of the ready callback and put it in a 'setTimeout()' which delayed the call by 1 second but that didn't help. Here's the console output:

Finished load of: file:///var/mobile/Applications/...app/www/index.html
 InAppPurchase[js]: setup ok
 InAppPurchase[js]: load [...]
InAppPurchase[objc]: Getting products data
InAppPurchase[objc]: Set has 13 elements
InAppPurchase[objc]: - ...
InAppPurchase[objc]: start
THREAD WARNING: ['InAppPurchase'] took '38.044922' ms. Plugin should use a background thread.
InAppPurchase[objc]: productsRequest: didReceiveResponse:
InAppPurchase[objc]: Has 13 validProducts
InAppPurchase[objc]: - ...
InAppPurchase[objc]: productsRequest: didReceiveResponse: sendPluginResult: (...)

Thanks for the help. I really like how you cleaned up this plugin. The log outputs are really helpful.

@wootwoot1234
Copy link

Here's my code (after removing the setTimeout()). Maybe I'm doing something wrong.

window.storekit.init({
    purchase: function (transactionId, productId, transactionReceipt) {
        console.log('purchased: ' + productId);
    },
    restore: function (transactionId, productId, transactionReceipt) {
        console.log('restored: ' + productId);
    },
    restoreCompleted: function () {
        console.log('restoreCompleted');
    },
    restoreFailed: function (errCode) {
        console.log('Error Code: ' + errCode);
    },
    error: function (errno, errtext) {
        console.log('failed: ' + errtext);
    },
    ready: function () {
        var productIds = ["..."];
        window.storekit.load(productIds, function(validProducts, invalidProductIds) {
            console.log("load callback");
            $.each(validProducts, function (i, val) {
                console.log("id: " + val.id + " title: " + val.title + " val: " + val.description + " price: " + val.price);
            });
            if(invalidProductIds.length) {
                console.log("Invalid Product IDs: " + JSON.stringify(invalidProductIds));
            }
        });
    }
});

@wootwoot1234
Copy link

Hey Jeff.

Never mind my last couple of comments. You're correct, it's working. I just stripped my code down to nothing but the in app purchase and the load callback fired so there's something wrong somewhere else.

Thanks again for this plugin.

Oh, one last thing. The readme.md file talks about some functions that no longer exist. If you want I'm happy to clean it up.

@j3k0
Copy link
Owner

j3k0 commented Oct 3, 2013

Hi wootwoot,
Of course feel free to clean the doc :) Any help to maintain this plugin is appreciated!

@j3k0 j3k0 closed this as completed Oct 9, 2013
j3k0 pushed a commit that referenced this issue Feb 7, 2015
Add triggers for hooking into restore failed or completed
dkarzon pushed a commit to dkarzon/cordova-plugin-purchase that referenced this issue Aug 8, 2015
j3k0 pushed a commit that referenced this issue Dec 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants