Search Unity

[Solved] iOS Promotional IAP only working when the app is already in the background

Discussion in 'Unity IAP' started by Bruder, Aug 17, 2017.

Thread Status:
Not open for further replies.
  1. Bruder

    Bruder

    Joined:
    Aug 9, 2014
    Posts:
    56
    HI Guys,

    I have integrated the new Unity iAP (with the new iOS promotional iAP) and when i am using the link for testing:
    (itms-services://?action=purchaseIntent&bundleId=XXXXX&productIdentifier=gYYY) it only works when the app is already opened in the background.

    Looking at the logs. when the app is closed and i use the link, the app is opened, but it does not get in the ''ProcessPurchase" callback (but when the app is in the background it does get into this function).

    Any ideas why?
     
  2. JuGGerNaunT

    JuGGerNaunT

    Joined:
    Oct 28, 2014
    Posts:
    9
  3. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @JuGGerNaunT

    If you aren't listening for purchases when the app starts, then you may miss purchases that are initiated outside the app (either from the App Store or through promo codes). It is also an Apple requirement.
    https://developer.apple.com/library/content/technotes/tn2387/_index.html

    @Bruder

    As mentioned, the Purchasing system has to be initialized when the app starts for the promo purchases to work. However, if you are doing that and it still doesn't work, please let me know and we'll look into it.
     
    x0r and ilmario like this.
  4. Bruder

    Bruder

    Joined:
    Aug 9, 2014
    Posts:
    56
    Hi @ap-unity ,

    We still don't see the purchase event (only in case the app is closed).

    We are working on that issues for few days now and it seems that everything is ok from our side (and of course initializing the IAP is one of the first things we do)

    Can you please take a look on it? we will be happy to supply more information if needed.

    Thanks
     
  5. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @Bruder,

    Thanks for the extra details. We are looking into doing some more testing on this feature next week. I will update you when I have more information.
     
    User340 likes this.
  6. Bruder

    Bruder

    Joined:
    Aug 9, 2014
    Posts:
    56
    Hi @ap-unity ,

    We just found out something interesting about this. when we turned off "Log In-App Purchase Events Automatically" in our Facebook console, it started working. It seems that Facebook Unity SDK (10.7) somehow prevent the call to 'ProcessPurchase' callback.
     
  7. JuGGerNaunT

    JuGGerNaunT

    Joined:
    Oct 28, 2014
    Posts:
    9
    I tested on other project with integrated Facebook SDK and have same issue with "turned on "Log In-App Purchase Events Automatically"".
     
  8. pivnix

    pivnix

    Joined:
    Mar 21, 2012
    Posts:
    10
    Hi everyone,

    beside Facebook SDK, AdMob plugin with default settings also may be the reason of this behaviour.

    Actually general the problem is that SKPaymentQueue will fire an event with promo IAP once as soon as it will have at least one observer. As some of analytics/ads plugins have feature of auto IAP reporting, they add their observers on app launch and tells SKPaymentQueue that game ready to handle events when it's not.

    Due to apple docs, event handler may store SKPayment for promo IAP and proceed it later when game will ready to handle it.

    So for properly implementing this feature seems few changes require for Unity IAP:
    • Separate calls for adding observer and query SKProducts with SKUs. Now seems it incapsulated in init method that could be delayed for call while waiting for receiving SKUs list from server, for example
    • Add option to store SKPayment and proceed it later in game

    @ap-unity, tell me plz if i have any mistakes in my description, and if we could wait for implementing features i suggest in anyway in near feature?
     
    Voxel-Busters and ilmario like this.
  9. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @pivnix,

    Your description of the problem is correct, however, your proposed solution may still run into this issue. It will always be a race for whoever gets to SKPaymentQueue first. We have no control over what AdMob or Facebook do in their SDK.

    Currently, the only workaround is the one mentioned: Disable the "Log In-App Purchase Events Automatically" feature in Facebook SDK or equivalent features in other SDKs.

    The Facebook FAQ has details on how to disable this feature:
    https://developers.facebook.com/docs/app-events/faq#faq_302009043463425
     
  10. pivnix

    pivnix

    Joined:
    Mar 21, 2012
    Posts:
    10
    @ap-unity, thanks for answer

    i understand that you have no control over any 3rd party plugins and SDKs that may be implemented, and impact that they can have on the project, but:

    Due to iOS In-App purchase best practice, observers should be added on didFinishLaunchingWithOptions delegate, so if Unity IAP may have option to add itself observer on this point, race problem won't be relevant as promo IAP callback doesn't call immediately after first observer added and invoking order of observers doesn't matter in this case.

    But this scenario anyway require Deferring or Canceling a Transaction feature implemented, for querying stored promo IAP SKPayment later in app.
     
  11. Deepscorn

    Deepscorn

    Joined:
    Aug 13, 2015
    Posts:
    25
    What do you say, @ap-unity ? Deferring or Canceling a Transaction is needed not only to resolve this issue, but for another use cases too. For example, we need to cancel a transaction if the user has already unlocked the product they are trying to buy
     
  12. Xsindrom

    Xsindrom

    Joined:
    Mar 20, 2016
    Posts:
    2
    Hi, we have recently tried this feature and we can't make it work. We created special scene to initialize the iap and we are sure that there are no other plugin initializations. We get an error <Error>: [SKPaymentQueue]: Tried to send purchase intent: <our product_name> to delegate, delegate does not respond to method paymentQueue:shouldAddStorePayment:forProduct. However if we reload game quickly, we get our transaction. Can u advice anything?
     
  13. ilmario

    ilmario

    Joined:
    Feb 16, 2015
    Posts:
    71
    It seems we are also having this same problem in an (unreleased) game of ours, though I haven't tested it much yet.

    It would be very nice to get this initialization and purchase on iOS via promoted IAP's 100% working in time before iOS 11 public release, as it offers potentially big ASO-possibilities - if it works reliably, which Apple will enforce or reject the app, probably.
     
  14. ilmario

    ilmario

    Joined:
    Feb 16, 2015
    Posts:
    71
    Another question:
    - Can we fix some of the issues by ensuring UnityIAP at the start of the initial scene AND the relevant component have their execution orders set so theyre used first?
     
  15. lindsaytalbot

    lindsaytalbot

    Joined:
    Sep 11, 2015
    Posts:
    28
    I am testing on an iOS 11 beta device building with Unity 5.6.1 and the latest version of Unity IAP. I am initialising the store in a method called during [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] and am having the same issue. Only works if app is open in the background.
    Not using Facebook or AdMob SDK, but I am using various Analytics providers and HeyZap + UnityAds + Vungle
     
  16. lindsaytalbot

    lindsaytalbot

    Joined:
    Sep 11, 2015
    Posts:
    28
    Deleting all of our video providers fixed this issue, but that's far from ideal. Will follow up with HeyZap to see if they can toggle a switch for "Log In-App Purchase Events Automatically"

    Edit: Resolved as per HeyZap! docs

     
    Last edited: Sep 5, 2017
  17. Xsindrom

    Xsindrom

    Joined:
    Mar 20, 2016
    Posts:
    2
    So any ideas or solutions for this issue?
     
  18. Joppers

    Joppers

    Joined:
    Apr 4, 2014
    Posts:
    9
    I've also run into the error mentioned above when the game is not already running in the background and needs to be started to complete the App Store purchase (using Unity IAP 1.13.1):

    (StoreKit)[729] <Error>: [SKPaymentQueue]: Tried to send purchase intent: gold_pack_3 to delegate, delegate does not respond to method paymentQueue:shouldAddStorePayment:forProduct

    I suspect the issue here is that UnityIAP does not add the SKPaymentTransactionObserver until the product list has been received from Apple, hence there is no delegate present to respond to the purchase intent.

    I reworked our boot flow to initialise UnityIAP first, before any other subsystem, but am still seeing several seconds (on an iPad mini) between requesting products and adding the SKPaymentTransactionObserver, as this logging shows:

    2017-09-15 11:34:32.450091+0100 cccg[261:6154] UnityIAP:Requesting 13 products
    2017-09-15 11:34:37.524536+0100 cccg[261:6154] UnityIAP:Received 13 products
    2017-09-15 11:34:37.796610+0100 cccg[261:6154] UnityIAP:addTransactionObserver


    With promoted IAPs, Apple passes the SKProduct and SKPayment info with the delegate shouldAddStorePayment. If the SKPaymentTransactionObserver is added as soon as UnityIAP is initialised rather than waiting for the product list to be retrieved then I expect the delegate would be found and the purchase flow could start?

    Many thanks

    Steve
     
  19. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You can expect an update for this issue soon (hopefully within a week or so)
     
  20. Joppers

    Joppers

    Joined:
    Apr 4, 2014
    Posts:
    9
    That's great. Thanks JeffD
     
  21. Joppers

    Joppers

    Joined:
    Apr 4, 2014
    Posts:
    9
    Hi,

    Thanks for the promotional IAP fix in build 1.13.3.

    I was wondering if there is any way to determine whether a promotional IAP purchase has been requested by the App Store when the app is booted or brought back to the foreground?

    As far as I can tell, the game only knows about the purchase when ProcessPurchase or OnPurchaseFailed is called, and not before?

    We would like to make sure that the user can not trigger other server calls or game events that could modify state if a promotional IAP purchase request is pending user action, but it does not seem possible to tell that that is the case?

    Many thanks

    Steve
     
  22. marshmallowgames

    marshmallowgames

    Joined:
    Aug 1, 2016
    Posts:
    5
    This is very important to us as well. We develop app for kids and we are required by Apple to present a Parental Gate before the purchase process begins.
    But we have no way right now the detect when this purchase process will start.

    Do you have any idea?

    thanks a lot
     
  23. Joppers

    Joppers

    Joined:
    Apr 4, 2014
    Posts:
    9
    A callback from UnityIAP would be extremely useful. When initiateQueuedPayments is called during addTransactionObserver, and when shouldAddStorePayment returns YES (in UnityEarlyTransactionObserver).

    I think these are the two cases when a promotional IAP is started?

    Steve
     
  24. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @Joppers, @marshmallowgames

    Unfortunately, that isn't possible with the current plugin, but it is a feature we could add to a future version. I have already made sure the team is aware of this request.
     
  25. Joppers

    Joppers

    Joined:
    Apr 4, 2014
    Posts:
    9
Thread Status:
Not open for further replies.