- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I've read the article about in-app-purchasing written for the xdk (https://software.intel.com/en-us/xdk/docs/html5-hybrid-apps-with-cordova-and-in-app-purchase). I've implemented it, but haven't figured out how to test it. I've got everything setup including the sandbox user, but I can't figure out how to open it in xcode to test?
Step-by-step instructions for opening my app in xcode so I can test the in-app-purchasing plugin with my sandboxed user would be super-fantastic! Please :)
Thanks!
K'shin
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would recommend looking at the "Debug on Device" capability in the "Test" tab. You might also want to look for debugging tips here:
https://software.intel.com/en-us/xdk/docs/lp-debugging
I don't think there's an easy way to run XDK apps in XCode.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have spent a bit of time with the IAP plugin, the following should get you started.
- Make sure you have placed the distribution_adhoc.mobileprovision and distribution_appstore.mobileprovision certificates in your application www folder. You generate these at developer.apple.com. You then need to go to Intel XDK Projects Tab >> Build settings >> iOS and select both of these certificates under ad hoc provisioning file and production provisioning file.
- You cannot test your in app purchase with any iOS device, the UUID of your device must be registered at https://developer.apple.com/account/ios/device/deviceList.action and that device also needs to be selected in your distribution_adhoc.mobileprovision certificate.
- Go to https://developer.apple.com/account/ios/profile/profileList.action?type=limited and check that your development provisioning profile has in app purchase service enabled.
- Intel XDK >> Projects Tab >> Build settings >> iOS. Choose "adhoc" as the provisioning profile for testing with your sandbox user, when you complete the app and build for the app store, you need to choose "production".
- Log into https://itunesconnect.apple.com ,select your application, then the in app purchase tab. Make sure the product ID for your purchases match the app id that you setup in XDK. So for an example, my app ID inside Intel XDK >> Projects Tab >> Build settings >> iOS is com.yourcompany.yourappname, so the in app purchases in iTunes connect need to have product IDs such as com.yourcompany.yourappname.purchase1, com.yourcompany.yourappname.purchase2 etc.
- You cannot test in app purchase through the XDK emulator or app preview, you must compile the app in XDK using the build tab, download the resulting .ipa file to your PC, then double click the .ipa file, open it with iTunes and it will install the application on your real iOS device.
- Before you test in app purchase on your device, go into settings >> iTunes on your device and log out. You cannot log in to the app store with your sandbox user or Apple will disable your sandbox user account. Only enter the sandbox username and password inside your app.
- You do not need to submit the app to the app store for in app purchases to function, you just need an application setup in itunes connect and have in app purchases setup for that application.
Hope that helps..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks C B.
Everything listed above has been done but you answered the question (You do not need to submit the app to the app store for in app purchases to function) I hadn't asked but was going to (so thanks for reading my mind!).
So you were able to test your in app purchase without xcode? I can already run the app on my device, but it doesn't ask me to login. It's my understanding it will only ask me to login if I'm running it through xcode. So the store isn't being registered and I'm just getting the "Invalid" note in my div (instead of the price from the store). How did you test your in app purchase?
Cheers,
K'shin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Dale,
I get an error saying it can't install app preview, suggest: retry.
I've built the signed app preview api and dragged it into itunes and pushed it onto my device but on my device it just says Installing... and has for 15 minutes now. Nothing seems to be happening. Trying to install through the xdk again gives me the same error as before.
That's the first time I've had to create a p12 file. That went smoothly, though I used the same cert I've been using to test the app on device before I added IAP, I didn't generate a new one with the csr.
Any ideas how to get it to actually install?
Thanks for your help!
Cheers,
K'shin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There have been some download problems with Amazon that might be causing the errors you're seeing. It was working better for me today, also worked much better for me when I downloaded over my home network rather than work network, where there is a proxy and firewall.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Paul,
I've just tried it again. The XDK throws the same error when trying to install the custom App Preview directly on the device, but it does allow me to save it to my hd before that. So I've loaded it into iTunes and put it on the iPhone 5 running 7.1.2 through iTunes sync. It shows up and says App Preview under it, but no icon, just the apple placeholder. When I tap on it it switches the name to Installing... and doesn't change.
I guess I'll try again tomorrow.
Thanks for your help!
BTW, I had to load the (modified with my Android license) IAP plugin into my WWW folder and create an intelxdk.config.additions.xml file containing my Android license and the plugin details in order to get it to load and build for both iOS and Android. Once I get it tested and working I'll write up a paper with step-by-step instructions and post it in the IDZ for all to benefit.
To All: Has anyone successfully tested the IAP on an iOS device with an app built using the XDK? If so, how?
Apple says you have to load run it in xcode, then you're prompted to login with your sandboxed user, once signed in you can run test transactions.
Cheers,
K'shin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi K'shin,
You don't need Xcode at all to test IAP, Apple will keep pointing you to Xcode because they want you to write the whole app in Xcode.
So in summary, once you have built something with XDK / Cordova you don't need Xcode at all. **Actually you do need application loader within XCode to submit the finished application into the app store, but that is the only reason. When your in development, you only need Intel XDK to get IAP working.
Looks like you are almost there, just a couple of pointers.
IAP will only work within the native app you have installed on your phone, it will not work in App preview on the device. The app calls up storekit libraries when running, and these are not available inside app preview, only a natively installed app can do that.
You will only see a login prompt when you try to make a purchase in your app, or if you hit the restore purchases button. Other than that, the app will stay quiet and won't ask for a login.
Once you install the app onto your device with itunes, try to make a purchase and it should prompt you for sandbox account.
Another good tip, ensure you have accepted all the legal agreements in itunes connect, especially around in app purchasing and your bank details. The storekit libraries will not be available for any of your apps until you accept the legal agreements and enter your bank details.
If you are seeing "invalid product" inside the app, this suggests the purchase items you are trying to register to storekit are different than what you have setup in itunes connect under in app purchases. See the following code snippet and double check your main.js file in the Intel XDK IAP app.
store.register({ id: 'com.company.application.purchase1', alias: '100 coins', type: store.CONSUMABLE }); store.register({ id: 'com.company.application.purchase2', alias: 'full version', type: store.NON_CONSUMABLE });
(replace "company", "application" and "purchase1 / purchase2" with your real names from itunes connect.) . The alias can be anything and is only used inside your app by javascript to show / hide divs depending on purchase status. The product type must also match what you have setup in itunes connect.
Check that your in app purchases product ID in itunes connect are also
com.company.application.purchase1 and com.company.application.purchase2
If they do not match, you will get "invalid product ID" div displayed instead of the actual purchase buttons.
Also check in Intel XDK >> Projects Tab >> Build settings >> iOS that your App ID is also
com.company.application
There is a good page on storekit at https://github.com/j3k0/cordova-plugin-purchase/blob/master/doc/api.md#registering-products
Also check that your certificates in https://developer.apple.com are NOT wildcard certs such as com.company.*. In app purchases do not work with wildcard apple certs, your certs for in app purchases MUST reference the application name such as com.company.application
I find that during testing it is much easier to use consumable purchase items, as these expire and you are able to buy them repeatedly with your sandbox account. Non consumable items can only be bought once per sandbox account and cannot be "un-purchased". You then need to create a new sandbox account to buy a non consumable item again. Also don't delete old sandbox accounts for your application during testing, there appears to be a bug within iOS or iTunes store that continually asks for the original sandbox account that made the first purchase, and if you have deleted that sandbox account you cannot enter the username & password and get stuck in a kind of loop, so a good tip is to only create new sandbox accounts.
Another little "quirk" I have found is that if you make any updates to your app and rebuild it, you must delete the old version off your device first, double click the new version of the app and select "replace" when prompted by itunes. Then sync your device with itunes and the new version of your app will be installed.
if you want to put your code up on Codepen or better yet, fork the https://github.com/gomobile/sample-in-app-purchase build and we can work on your own private version, I would be more than happy to have a look for you.
Let me know how you go.
cheers
cb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks CB,
I'm not actually working in the example. I'm working in my own code. Everything is in place and the same in the code and in the stores except the bank account as we just setup the company and still haven't made it into the bank for it. Perhaps that's what it is. I was under the impression that the agreements had to be in place (they are) but not the bank details.
My code will show "Invalid" if it can't even connect to the store. I'm thinking that's where it's at now with iOS.
I am testing the Android in-app purchasing as well and it is connecting, so at least I'm making headway there. Once I have all of that working I'm thinking it will probably just work on iOS, once I have the bank account details added in, I guess.
Good to know about not deleting the used sandbox users, thanks!
I'll report my progress here.
BTW, this is my second XDK app. I've had an app in the Android, iOS (had to buy a Macbook just for uploading), Blackberry and Amazon stores for about 3 years now thanks to the XDK! I am enjoying the cordova code base for this app. It was all Appmobi when I started my first one. Will port it over to cordova for version 2.0 when I'm 'done' with this one. Like they're ever done...
Thanks for all your help!
Cheers,
K'shin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Still unable to get the signed App Preview onto my device, btw. Same issues, nothing has changed for me.Using latest XDK 1826 (which is quite buggy for me in general).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi K'Shin,
Yes, it appeared you had done this before..I thought I would throw all the steps in for the benefit of others if they stumble across this page. It certainly gave me a frustrating 2-3 days while I figured out all the steps.
I had a quick look at your time management app on the app stores, it looks great well done.
What happens when you try to install the app through itunes? Does it install the app onto the device?
How big is the .IPA file? Do you have enough space on the device? Delete the app on the device if it exists, and try a hard reboot (hold power and home for 5 seconds). This should clear out any caching or corruption of the app, especially if you have loaded and deleted the app a few times, however this is rare.
BTW, when you say signed app preview, I gather you mean "compiled application through Cordova build?"
I am just wondering if you are referring to the Intel App Preview app on the device vs your actual compiled cordova app on the device..? I gather you know this already, but once the app is compiled through the build service, it is totally separate to Intel App Preview.
What is your app name called under Intel XDK >> Projects >> Build settings >> iOS >> App Name? This is the text you should see under your icon on the device.
P.S Have you got the following code (or a version of it inside your app?)
var initStore = function() { if (!window.store) { log('Store not available'); alert("The In-App Purchase Cordova plug-in is not supported or available."); return; }
This will tell you if the storekit libraries are loading / not loading..it seems they are loading if you are getting invalid product..but worth checking all the same
Cheers
cb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey CB,
Thanks! I like it, but it requires a level of commitment that not too many are willing to give. The stuff you can find out about your life is pretty cool: if you have questions it can provide answers, if you use it for a while. But I probably also like data more than the average person... It will be cooler once ported to cordova.
I install my app by clicking on the email link from inside my device. Works like a charm. Yes I am referring to the Intel Signed App Preview app that the xdk tries to install from the DEBUG tab. That's what I'm having trouble with. I can't even sign into the standard Intel App Preview for some reason, so I can't use the TEST tab for it either. Bit frustrating! So really, at the moment I have no way of debugging it in iOS anyway, because the emulator only works with their plugins...
I've actually got the in app purchasing working on my Android device, so things are setup properly in there. Just a few kinks to work out atm. I'll try again with the iOS once I put in the bank details. Hopefully that's what's missing.
Not sure how I'm going to debug it without being able to use the TEST or DEBUG tabs though.
Cheers,
K'shin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The .ipa is 6.1 mb and there's over 1 gb of space on the device...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi K'shin,
OK that makes sense, your trying to use the debug tab and install the signed app preview onto the device. Yes I also had a fair bit of trouble getting the signed app preview onto my device, it does work on android devices I noticed. I don't use the debug tab at all.
I can give you another two ways of debugging the app, it's probably not the Intel way, but certainly works fine for me and allows me to use any plugin, including IAP.
Anywhere you want to debug your code on the device, change your code to suit the following:
Debug method 1 - popup logs to screen
Anywhere you currently have
console.log("something happened here");
change to:
alert("something happened here");
At least then you can see the debug points as popups on the screen, instead of them being logged to the console..which you can't view without the intel xdk debug app installed.
Debug method 2 - write to div on the page
This will allow you to see debug events on the page, and they are updated live as they happen.
Create a new function in your .js file with the following
// log both in the console and in the HTML #log element. var log = function(arg) { try { if (typeof arg !== 'string') arg = JSON.stringify(arg); console.log(arg); document.getElementById('log').innerHTML += '<div>' + arg + '</div>'; } catch (e) {} };
Create a div in your HTML page with
<div id="log"></div>
Then when you want to write/debug into that div use the following function
log('something happened here');
When your ready to launch, change them all back to console.log..or comment them all out and rebuild the app
Let me know how you go.
cheers
cb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks cb, I am using both of those methods. JSON.stringifying and alerting the objects so I know what to do with them. Certainly not ideal, but doable!
In Android, now that you can publish to Alpha, it's pretty easy to setup and debug the code. After you publish the first one you can test builds against their system without publishing the new builds, just installing them on your devices with sandboxed accounts on them.
Did you ever get the signed app preview onto your iOS device and working?
Cheers
K'shin

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page