Search Unity

IAP Error after cancelling a Google Play subscription and returning to app

Discussion in 'Unity IAP' started by rainandgames, May 7, 2021.

  1. rainandgames

    rainandgames

    Joined:
    Aug 6, 2018
    Posts:
    12
    Hi,

    I've implemented IAP Google Play subscriptions into my app, and so far everything is working great in my test environment. I have an OnInitialized function in my IAPController that gets my product list from controller.products.all. With this product list I am able to show the status of various subscriptions. When a user subscribes, the information in the product list automatically updates and I can show the new information.

    This is all great. I've encountered a problem now though. When a user cancels a subscription in Google Play and returns to the app (without restarting it), the IAP listener doesn't get notified. So I can't display the new subscription information. If I manually update my scene and try to pull product info from my product list, I get the error:

    CodelessIAPStoreListener attempted to get unknown product

    If I restart the app, I correctly see the cancelled subscription. Where am I going wrong?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    There won't be any real time notice. You need to restart the app.
     
  3. rainandgames

    rainandgames

    Joined:
    Aug 6, 2018
    Posts:
    12
    Thank you for the fast response! That works for me. What would be the best way to catch this error and force an app restart?
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Not entirely sure, it sounds like you would need to modify the IAP Listener script for Codeless, but that is not recommended. Do you have code to "pull the product from your product list"? Otherwise, I might suggest scripted IAP and start with the Sample IAP Project here. Codeless was not designed for the scenario where you cancel the subscription during gameplay. https://forum.unity.com/threads/sample-iap-project.529555/#post-6950270
     
  5. rainandgames

    rainandgames

    Joined:
    Aug 6, 2018
    Posts:
    12
    Thanks again! I do have code for that, I'll look into the scripted IAP to find a solution.