Welcome! › Forums › Unity Plugins › In-App Web Browser › Android OnApplicationPause and in-app purchase
- This topic has 7 replies, 2 voices, and was last updated 4 years, 12 months ago by Tethip.
-
AuthorPosts
-
October 15, 2019 at 11:42 am #1748TethipParticipant
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.
October 15, 2019 at 6:31 pm #1753PiotrKeymasterWhat is “OnApplicationPause”? Is it some Unity API?
October 15, 2019 at 7:05 pm #1755TethipParticipantYes, it’s called automatically when the app is paused/unpaused, by the OS for instance.
Here’s more : Unity3D OnApplicationPause documentation
October 16, 2019 at 7:21 pm #1762PiotrKeymasterFrankly, 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.
October 17, 2019 at 10:06 am #1763TethipParticipantI 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.
October 21, 2019 at 5:20 pm #1789TethipParticipantHi,
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
October 21, 2019 at 7:10 pm #1792PiotrKeymasterIt should be fairly easy to add callbacks like “application become active” / “application become paused” while browser was open, would that be helpful for you?
October 22, 2019 at 12:52 pm #1799TethipParticipantIt 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.
-
AuthorPosts
- You must be logged in to reply to this topic.