Does Phonegap 3 includes a method "onExit" or "onDestroy" ? I would like to perform some actions before the app closes.
Basically, I want to kill an admob.
Well, after some exploration seems like phonegap api have no such event as onDestroy. This functionality could be implementat in some states for android, course a bit creepy, but in iOS this is not avalible anyway.
Android logic:
if user presses the home button app fires pause event, but application is not closed, so window.onunload will take no reaction. From this point phonegap app's webView doesn't recieve any event. But if user presses back button on first page or application was closed programmatically window.onunload must fire. I think there is a way to realise some kind of native callback by creating a java background process.
iOS logic:
In iOS, application can't close itself by some kind of apple sequrity statements. So app never closes untill user do this by double pressing the home button and killing the app. By some reasons apple dosen't allow apps do anything in background, excluding push notification recievement. So app can detect only it's transfer from foreground to background
I think all you have is onpause/onresume
Related
I'm doing a PWA using Vue.js, i know that cordova can handle the android/iOS back button (the device back button, not the browser one), so it's ok.
How can i detect this on vuejs?
Device back button is native feature of Android/ios, so can not detect event on click.
I've surveyed most of the questions on the web but this still gets me confused....
My question is, how to detect hide/leave event of a website tab in mobile phone browser, my situation is NOT about closing the tab(like pressing the X button at the up-right or up-left corner), and also NOT about closing the whole mobile browser app directly.
(Previously, I have a webpage with a websocket connected to receive the encoded audio content, and then use AudioContext to play the sound)
Below are the two situations I've encountered.
When I press the HOME button and the mobile browser app hides.
When I click a url in the Messenger app or Facebook app of my iPhone, and press the Back button to go back.
the url link is opened in the in-app browser which made by Facebook directly, and when I press the back button on the left-up corner, the view jumps back to the Messenger window or the Facebook timeline.
In these two cases, I have listened beforeunload (and also pagehide event for iOS), but neither one is catched. And I have found that the websocket connection is still connecting and the audio is still playing. It seems like the whole page is still running somewhere(but you cannot see). I also tried listening to a div :visible, but it is still giving me true when I pressed the home button or leave the facebook in-app browser.
Is there still any way to detect these two kinds of situation? I want to turn off the streaming sound and also close the websocket connection.
Just found the answer....
Page Visibility API https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
Im working on a chrome app, currently testing it using developer mode. Im trying to open my app in full screen whenever user click on app shortcut (chrome -> Apps -> MYAPP). I've managed to do this on button click using requestFullScreen() method but it can only be done when user loads the app and click on fullscreen button. What i want is to launch the app in fullscreen mode. Is it possible to convert that onClick eventlistner to onLoad?
Any help will be highly appreciated.
Thanks
You can set the state option to "fullscreen" when calling chrome.app.window.create. Note that you will also need to declare fullscreen permission in the app manifest.
I am trying to create an app which does some work when it becomes visible, and does other work when it goes away. This is typically accomplished with the page visibility api (http://css.dzone.com/articles/using-html5s-pagevisibility) but this is not currently supported in windows 8: http://msdn.microsoft.com/en-us/library/ie/hh673553(v=vs.85).aspx
There are callbacks onactivated and oncheckpoint but these are for the process lifecycle and are not necessarily related to app visibility. Specifically, an app can go to the background for quite some time before it is suspended.
Any help would be appreciated.
-- Henry
I think you want the visibilitychange event. See the Document documentation here. More on application lifecycle events here.
App visibility
When the user switches from your app to another app,
your app is no longer visible but remains in the running state until
Windows can suspend it (for about 10 seconds). If the user switches
away from your app but activates or switches back to it before Windows
can suspend it, the app remains in the running state.
Your app doesn't
receive an activation event when app visibility changes, because the
app is still running. Windows simply switches to and from the app as
necessary. If your app needs to do something when the user switches
away and back, it can handle the VisibilityChanged |
msvisibilitychange event.
The visibility event is not serialized with
the resume or activation events. Don't assume that these events come
in a particular order.
If you want to track app focus switches you could use window.onblur and window.onfocus. Especially in multimon environments that's helpful.
I m using HTML5 and JS to build the app.
In app i have facebook feature, after login to facebook when i use post to wall feature, the feed dialog comes and after entering the text when i tap on Share button the SoftKeyboard of iOS does not goes off. Same app when i run it on iOS 4 device it running properly, I tried to set focus to other element like other button of the app after getting the response of post to wall in the callback function but it did not work
I also was facing same issue but when I updated Phonegap1.7.0 the issue was resolved.