0 Favourites

Cocoon.io with IAP

  • The built in IAP object lists Coocon.js as a compatible platform here https://www.scirra.com/manual/173/iap. Is this still working with Cocoon.io? I'm having trouble with the Cranberry Cordova IAP plugin not firing the purchase product action and I'm trying to find another IAP solution.

  • After looking around I see some people have the Cranberry IAP working but all the posts I see are using XDK and exporting to Android. Here is how I have my things set up.

    Splash screen

    On Start of layout>

    CordovaIAP>Add product IDs "removeads"

    CordovaIAP>Request store listing

    Main Menu

    On touch(remove ads button)>Purchase product "removeads"

    On touch(restore purchases button)>

    CordovaIAP>Request store listing

    CordovaIAP>Restore purchases

    Game is compiled in Cocoon.io, config.xml is setup correctly all plugins match installed plugins in Cocoon. Got everything set up correctly in Xcode(provisions, bundle ids, certificates, etc), IAP is set up correctly in iTunes Connect and enabled for the app. I build a development build and deploy it straight to iOS device. I'm getting nothing happening at all when I click on the buy remove ads button, the restore purchases give me a prompt to sign in(which i would sign in using my sandbox account if i actually had the purchases working). Not sure why I'm getting nothing on buy button with Purchase product action on it. Not sure if I have my events set up wrong, if it's something with the plugin or what. Anybody that has any advice would greatly be appreciated, Artpunk , AndreasR , cranberrygame . Thanks.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • You can use the Cocoon inapp Plugin,

    https://shatter-box.com/knowledgebase/c ... he-plugins

    Regards

    Andy

  • Hey twg

    I have Cranberrygame's Cordova iAP working on Android and iOS at the moment. But like you say the game was built with XDK not Cocoon.

    I am currently in the process of migrating the same game from XDK to Cocoon and decided I would also swap from Cranberry's plugins to Cocoon's own plugins for iAP and GooglePlay / GameCenter.

    So at this stage I can tell you that I have Cocoon's iAP plugin working for Android, but I haven't tested for iOS. In Android, the purchasing events, restore purchase events, and conditions for checking purchases all seem to work. Ill be testing iOS in the next few days, so ill be able to comment on Cocoon iAP on that platform soon.

    I tried to use the Cocoon iAP plugin in exactly the same way as I used Cordova iAP. When the game first loads up and the title screen is showing, check if the remove ads iAP has been purchased and if so restore the purchase.

    On Start of Layout

    Cocoon InApps - Fetch products from Store "removeads"

    Cocoon In Apps - Update product list

    On Products Fetch completed

    Restore purchase

    The events I use for purchasing the iAP are:

    On Touched 'Remove Ads button'

    Cocoon InApps - Purchase product "removeads"

    If purchase successful

    Hide the remove ads button

    Store a value in a dictionary, which is later used to disable Ads in game. This value is store in localstorage.

    Events linked to restore button for restoring purchase are same as events in the title screen but use 'On Touched "Restore Button"' rather than On Start of Layout. Hope that makes sense?

    A super useful trick that AndreasR showed me is how to use the consume purchase action to remove the purchased iAP from the game. That way you can test the iAP works multiple times.

    Add a sprite to the menu screen, with events:

    On Touched > Consume "Remove Ads" iap

    Now you can purchase the iAP again. One difference I noticed between CordovaiAP and Cocoon iAP is that the 'On Consumed' condition doesn't seem to fire for Cocoon's iAP (but does work for Cordova iAP).

    twg Hope that helps, sorry for wall of text. Let me know if you get it working on iOS, like I say Ill be battling iOS myself over coming days. So I can give better information once Ive got it working.

    Oh one other thing I wanted to say. You mentioned in your post about having a sandbox account. I never managed to figure out wtf the sandbox account was all about. I never managed to use it. I use the 'Internal Testers' section in iTunesConnect to test pre-release builds of my game for iOS.

  • Artpunk I haven't had any problems Cranberry plugins I'm using(NativeShare & Leaderboards) with my iOS Cocoon builds, I put the Cocoon dev app on the device yesterday with some debugging stuff in there and realized that the Fetch product list is failing every time(using CocoonIAP). After looking around I realized that one of my billing agreements required to have IAP in my games is pending and if it's not accepted Apple won't let your app access the IAP. My events are pretty much the same way yours are, so I think this is why my IAP isn't working right now. Gotta wait till they get back to me about that before I can test some more.

    The sandbox accounts are really helpful, really easy to test IAP with, just gotta set up a new sandbox account in your users and roles, only thing is it has to be a new email that is not your developer email account or an email account associated with any of your current tester or itunes connect user accounts. Just log out of the app store on your device, deploy the build to it then when you click an IAP it will ask you to sign in and you just use the sandbox account login. Just make you don't go into settings>App store and use your sandbox login there cause it will turn the sandbox account into a regular account.

  • Hi sudeep98 I replied on the cocoon forum.

  • I tried to use the Cocoon iAP plugin in exactly the same way as I used Cordova iAP. When the game first loads up and the title screen is showing, check if the remove ads iAP has been purchased and if so restore the purchase.

    On Start of Layout

    >Cocoon InApps - Fetch products from Store "removeads"

    >Cocoon In Apps - Update product list

    On Products Fetch completed

    >Restore purchase

    ...

    Events linked to restore button for restoring purchase are same as events in the title screen but use 'On Touched "Restore Button"' rather than On Start of Layout.

    Hi Artpunk, please can I ask you for some help?

    I've set my "Restore Purchase" button up the same way you've explained above but it doesn't work.

    My "Remove Ads" IAP works fine, but restore purchases does nothing.

    http://www.imagebam.com/image/41940b774396773

    I'd be very appreciative if you could look at my events here and let me know what I've done differently to you please!!

    Thanks!!

  • Dellaclearing sorry for no response I haven't been active on the forum lately. Did you get this working?

  • Dellaclearing sorry for no response I haven't been active on the forum lately. Did you get this working?

    Hi Artpunk thanks for writing back to me! No, I still haven't managed to get this working I'm afraid!

    Can you look at my image above please and let me know what I've differently to yours please?

    Thanks very much!!

  • Dellaclearing Your events look like they *should* work to me.

    Try this. First event:

    On Touched 'Btn_Restore' > Restore purchases.

    Disable your entire second event for the moment. Rather have an event that says:

    On Restore Purchases Completed

    + (Is product 'remove_ads' purchased) > set global variable etc.

    So basically leave out the 'fetch products' action and 'on fetch products' event.

    See if that works at all.

  • Dellaclearing Your events look like they *should* work to me.

    Try this. First event:

    On Touched 'Btn_Restore' > Restore purchases.

    Disable your entire second event for the moment. Rather have an event that says:

    On Restore Purchases Completed

    + (Is product 'remove_ads' purchased) > set global variable etc.

    So basically leave out the 'fetch products' action and 'on fetch products' event.

    See if that works at all.

    Hi Artpunk,

    I'm very sorry it took me so long to reply to you!

    To report back, it turns out I was doing something wrong the whole time! The APK I was testing on wasn't an official download from the Play Store, it was an APK I'd compiled and installe dstraight onto my phone!

    After publishing, the above didn't do anything, but I then reverted to the original instructions, re-compiled the APK and uploaded it to the Play Store and this time I was able to restore purchases on both Androind and my iOS version!

    I may be wrong, but can only assume that it was related to testing on versions not downloaded from the stores.

    Thanks for your help!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)