Is it possible to detect android back button on web app? - javascript

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.

Related

Is it possible to check if the user is trying to exit the page on iPhone?

Is it possible to check if the user is trying to exit the page on iPhone via Javascript?
So basically when the user swipes up the home button and the Browser Window is shown in the app gallery mode? Is there an event for that?
No there is not in my knowledge.
I don't think there is a way we can see if a person is trying to get out of a Javascript page in an iOS software.

Cordova Inapp browser reopens on android back button?

I use an 3rd-party Oauth page in an in-app browser to login into my application. On successful login, I close the in-app browser using its close method and move to my home screen. But on Android back button press, it moves back to the in-app browser login page. I'm using Cordova's exit method to quit the app on the back button pressed event. But somewhere I read that I should avoid using the exit method, as it is not a good practice. Can't I close the in-app browser forever to avoid using the exit method to quit my app?
Make sure you're handling the backbutton cordova event. Instead of exiting the app, why not just disable navigation back to that page. On back button event check the route you're going to and if its that page disable it.

Detect in Javascript/jQuery if mobile browser is not open or active

*I have searched online and on SO
I have a mobile site made in jQuery Mobile. If the user has navigated away from the mobile browser on their phone, (to another app), which would hide the mobile browser (but the mobile browser would still be running on their phone), I need a way in Javascript or jQuery to know when the user opens their mobile browser again.
I have packaged the mobile site as an app using PhoneGap and I currently achieve this by using the onResume() function.
You can detect when the tab or window is closed via the onunload and onbeforeunload events. These will trigger if the tab is closed, the back button is hit or an exit link is clicked.
There's a proposal to allow webapps to detect if they're in the foreground or not, the visibilitychange event, http://www.w3.org/TR/2013/REC-page-visibility-20131029/#sec-visibilitychange-event
It's partially supported, mainly by newer browsers, so depending on your needs it may work for you. http://caniuse.com/#feat=pagevisibility

Can I set a link of a Page On back butten of browser or android Device?

I am working in a mobile application using INTEL XDK.By Default android device or browser back button take back to the previous one, instead I need to redirect it to the another page according to given url.How cane I do this using javascript or Is there any other method in INTEL XDK?
You need to capture the backbutton event for that button. You can find more about that button here -> http://cordova.apache.org/docs/en/4.0.0/cordova_events_events.md.html#backbutton

Is there a onExit or onDestroy method on Phonegap 3?

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

Categories

Resources