PhoneGapp to foreground

487 views
Skip to first unread message

AdieuTheDesktop

unread,
Mar 17, 2012, 2:36:37 AM3/17/12
to phon...@googlegroups.com
Hello All,

I have been playing around with PhoneGap Build for just over a day now.  I do a great deal of coding with jQuery Mobile and for starters I am simply using a sample jQuery Mobile app with PhoneGap Build.  I am impressed at how well it works.  However, there is one thing I have not yet been able to figure out - how can I get my app to bring itself back up to the front after the user has switched to doing something else.  The scenario I have is this

a. The app requires an action to be performed by the user.
b. I use navigator.notifiction.beep/vibrate to call the user's attention.
c. I bring the app to the foreground (only I can't!)

Initially this is for Android but eventually I will have to do this for iOS too.  A related question - will beep/vibrate notifications work even on iOS without any changes to my code?

Giacomo Balli

unread,
Mar 17, 2012, 7:24:17 AM3/17/12
to phonegap
you can do beep/vibrate on iOS.
You cannot automatically bring the app to foreground unless using a
custom url scheme or notification (the user needs to initialize
opening the app in some way).

AdieuTheDesktop

unread,
Mar 17, 2012, 11:18:19 AM3/17/12
to phonegap
I have never owned an iPhone so I have no way of knowing what happens
on it. WhatsApp, the instant messaging app, on my Android pops back
to the foreground when it alerts me to an incoming message. Does that
not work on the iPhone? How does one do that on the Android for
starters - app back to foreground, I mean.

Giacomo Balli

unread,
Mar 17, 2012, 12:24:36 PM3/17/12
to phonegap
that works on iPhone also. That popup is a "notification".

AdieuTheDesktop

unread,
Mar 19, 2012, 6:21:17 AM3/19/12
to phonegap
On my Android phone if I do navigator.notification.alert(text) the
alert appears all right but if the app is not currently in the
foreground nothing happens - the alert pops up in the app but the app
does not come to the foreground, neither does the alert. Are we
talking a different kind of notification?

AdieuTheDesktop

unread,
Mar 19, 2012, 8:39:15 AM3/19/12
to phonegap
By notification here I assume you mean what turns up in PhoneGap as
navigator.notification with its alert, beep and vibrate methods? I
have the alert working on Android but it will not show up in the
foreground. I have come across references to Toast notifications
(Android) and Homescreen Badges (iOS) but I have yet to figure out how
I do those in PhoneGap via JavaScript. Is there any demo code/
tutorials on the subject. Googling around has not yielded anything
useful as yet. Any help would be much appreciated.

Giacomo Balli

unread,
Mar 19, 2012, 2:21:24 PM3/19/12
to phonegap
no, they are two different notification.
navigator.notification is a popup while your app is running and in
foreground
local notification (there is a plugin) is a notification that get set
at a specific time/date (usually) and gets fired when your app is int
he backgorund.
Push notification gets fired by your server.

They are already in order of ease of use... ;)
Reply all
Reply to author
Forward
0 new messages