Android OnApplicationPause and in-app purchase

Welcome! Forums Unity Plugins In-App Web Browser Android OnApplicationPause and in-app purchase

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1748
    Tethip
    Participant

    Hi !

    My app wokrs all the time with the browser open. For my app, i’ve made a button in my web site that comunicate with Unity with javascript to start an in app purchase via play store. It’s working perfectly fine.

    Here’s my problem.

    When the purchase starts, OnApplicationPause(true) is called. But when the purchase ends, completed or not, OnApplicationPause(false) is never called.

    It’s happen sometimes when I press the overview button. OnApplicationPause(true) is called when pressed, but OnApplicationPause(false) isnt’ always called when I reoppend the app.

    This is very critical for me, because Unity updates and callback aren’t called when it’s paused.

    Thanks for your help.

    #1753
    PiotrPiotr
    Keymaster

    What is “OnApplicationPause”? Is it some Unity API?

    #1755
    Tethip
    Participant

    Yes, it’s called automatically when the app is paused/unpaused, by the OS for instance.

    Here’s more : Unity3D OnApplicationPause documentation

    #1762
    PiotrPiotr
    Keymaster

    Frankly, I can’t say much without detailed look at the code. Maybe some browser lifecycle method might help you with it? E.g. when URL starts or finished loading.

    #1763
    Tethip
    Participant

    I understrand this will be a tricky one.

    Unity doesn’t catch events when it’s paused. Not even javascript messages from the browser.

    So when my app resume after the purchase (but still on pause == true), I can’t do anything except naviguate the web trough the browser.

    The only solution I found is to close the browser, and only then, OnApplicationPause(false) is sent by Unity. But I Have to do it manualy, because I can’t detect any event to do it automaticly. Not very user friendly.

    #1789
    Tethip
    Participant

    Hi,

    Here some more details where you can see some logs. (blurred part are useless and/or confidential)

    https://www.dropbox.com/s/hgyvqoybuqvuf1m/PbAndroidPause.jpg?dl=0

    It happen too when i’m sharing something with the native android API.

    In other words, when somthing shows up top of my app, Unity’s pause is called, but when I go back to my app, if the in app browser is still open, the end of the pause is never detected by unity.
    (so like I wrote before, no callbacks, no updates, no javascript messages)

    By the way, when the browser is running, Unity considers the focus always lost for the app. Not a problem for me, but could be for others.

    Thank you

    #1792
    PiotrPiotr
    Keymaster

    It should be fairly easy to add callbacks like “application become active” / “application become paused” while browser was open, would that be helpful for you?

    #1799
    Tethip
    Participant

    It won’t work, because Unity don’t get any callbacks while it’s paused.

    I found a poor but working solution.
    I close the in app browser just before an in app purchase or a share action that put the application on pause. When the purchase or the share is done, I reopen the browser at the last url.

    But this solution doesn’t work with the pause started with the home or overview buttons. The applications crashes in these cases.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.