Search Unity

[Closed] RegisterPurchaseDeferredListener called every app launch even after purchase was aproved

Discussion in 'Unity IAP' started by MariaAngelovaPD, Dec 15, 2017.

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

    MariaAngelovaPD

    Joined:
    Jun 15, 2017
    Posts:
    25
    UnityPruchasing 1.14.1, iOS.
    In our code we register a PurchaseDeferredListener during OnInitialized() using:
    extensions.GetExtension<IAppleExtensions>().RegisterPurchaseDeferredListener(PurchaseDeferredNotification);
    After releasing our game (which made it possible to test deferred purchases using ask to buy) we made a test of the feature: using three iOS devices signed in with a child apple account we attempted to make a purchase. For each device, correctly, the PurchaseDeferredNotification executed after going through the store dialogs and the game showed the relevant "purchase is awaiting approval" info dialog. For all 3 devices, if we then exit the app and launch it again we experienced that the PurchaseDeferredNotificationis is called right after OnInitialize completed so the game presented the player with the same "purchase is awaiting approval" info dialog at launch. Happens every time the app launches on all 3 devices. This was slightly unexpected for us and though we find it slightly annoying for the player it is still correctly representing the status of the purchase. Then we went ahead and approved the purchase on the 4th parent device. All 3 child account devices were eventually able to recognize the purchase was completed and changed the state of the game from trial to full game (which is very easy to spot when inside the menu of the game since the UI changes). However on all devices we continued to get the PurchaseDeferredNotification right after OnInitialize() if we close the app and relaunch it even though the purchase has been approved and the game has fulfilled it and switched to full-game mode. So even after completing the purchase, our players are still presented with the "purchase is awaiting approval" info dialog on app launch.
    We have currently opted to remove the info dailog so our PurchaseDeferredNotification routine does nothing apart from logging to avoid presenting the players with incorrect information of the purchase status.

    Code :
    public class IAPSystemIOS : IStoreListener
    {
    private const string FullGameProductId = "fullgame";
    private const string FullGameProductId_iOS = "fullgame_iOS";
    private bool IsFullGameProductId(string productId)
    {
    return String.Equals(productId, FullGameProductId, StringComparison.Ordinal) ||
    String.Equals(productId, FullGameProductId_iOS, StringComparison.Ordinal);
    }

    public IAPSystemIOS()
    {
    var module = StandardPurchasingModule.Instance();
    var builder = ConfigurationBuilder.Instance(module);

    builder.AddProduct(FullGameProductId, ProductType.NonConsumable, new IDs() {
    {FullGameProductId_iOS, AppleAppStore.Name}
    });
    UnityPurchasing.Initialize(this, builder);
    }

    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
    // ....
    extensions.GetExtension<IAppleExtensions>().RegisterPurchaseDeferredListener(PurchaseDeferredNotification);
    }

    private void PurchaseDeferredNotification(Product product)
    {
    if (IsFullGameProductId(product.definition.id))
    {
    D.LogWarning("***** IAP: deferred FULL GAME purchase");
    Dialog(Localization.Get("YOUR PURCHASE WILL BE COMPLETED WHEN IT IS APPROVED"));
    }
    }
    // ...
    }
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @MariaAngelovaPD I will check with the IAP team here, and will keep you updated.
     
    MariaAngelovaPD likes this.
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I have let the IAP team know, and they will be investigating further. If this turns out to be a valid issue, you might expect it to be included in a future release.
     
  4. MariaAngelovaPD

    MariaAngelovaPD

    Joined:
    Jun 15, 2017
    Posts:
    25
    OK, thank you. I will appreciate further info once they have investigated and know whether it is valid.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @MariaAngelovaPD Have you had a chance to test this with IAP 1.15 ? Make a project backup first prior to testing.
     
Thread Status:
Not open for further replies.