PhoneGap Build - Local Notifications

  • 6
  • Question
  • Updated 7 years ago
  • Answered
Is it possible to use local notifications with PhoneGap build? If so, are there any examples and/or documentation that I could follow to do this?

What I need to do is - setup a LN every 10 minutes that checks the phone's location, does a background query with a server (if the location has changed significantly) and alerts the user if appropriate. I have much of what is required coded and tested as an HTML5 webapp - I just need to wrap it into PhoneGap to be able to use local notifications.
Photo of etkit1

etkit1

  • 1 Post
  • 0 Reply Likes

Posted 8 years ago

  • 6
Photo of jwargo

jwargo

  • 79 Posts
  • 10 Reply Likes
I'm not sure what you mean by a local notification, but the PhoneGap Geolocation API allows you determine the device's location (either manually or via a listener - except on iOS of course). There's nothing special about this - any HTML 5 browser can do this, so of course PhoneGap can do it too.
Photo of jwargo

jwargo

  • 79 Posts
  • 10 Reply Likes
Oh, and you'd use the PhoneGap notification API to alert the user and XHR to communicate with the server.
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Etkit1,

If you wish to display notifications such as banner messaged to IOS users, then you will need to use plugins that build does not yet support.

https://github.com/phonegap/phonegap-...

Contains plugins for platform notifications.

Hope that helps.

Hardeep Shoker
Photo of leeblazek

leeblazek

  • 12 Posts
  • 1 Reply Like
I am also interested in this, I have used the notifications for push on PG1.3.0.

But haven't seen any working for cordova 1.5
Photo of mlavignasse

mlavignasse

  • 3 Posts
  • 0 Reply Likes
I was under the impression that Local Notifications is included in the Phonegap api. It is not?

Then what is this?
http://docs.phonegap.com/en/1.6.0/cor...

I am confussed
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Local notifications are supported (think of alert boxes), however platform specific notifications such as an ios banner message, or a message on Android's notification pull down are not.

The latter will require the use of a plugin.

Hardeep Shoker
Photo of mlavignasse

mlavignasse

  • 3 Posts
  • 0 Reply Likes
So then it is just a simple alert? What is the difference?

I was hopping for a Local Notification that could be raised at a set time, let says 1:00 PM, regardless if the program is running or not. At 1:00 PM popup a message and when you press a button, bring the application to the front so you can do what is needed.
Is that possible?
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Mlavignasse,

That is not supported via PhoneGap right out of the box however it is supported via a plugin (see my github link above); at this point PhoneGap Build does not support the type of notification you are trying to achieve.

Hardeep Shoker
Photo of vikas .s

vikas .s

  • 3 Posts
  • 0 Reply Likes
If so then is there any solution to use local notifications in our application?

i don want to go back to native development, Still 3/4 th of my application has been done and wrapped using PG Build.

What for PG Build is for. Am bugged up.
Photo of John Saya

John Saya

  • 68 Posts
  • 7 Reply Likes
I think PhoneGap Build would be a home run if it would support cross platform local notifications. Right now it's nearly impossible to create an app using Build that can make use of them.
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
It's a very likely candidate for a plugin supported by build in the future : )

Hardeep Shoker
Photo of Tobin Rysenga

Tobin Rysenga

  • 1 Post
  • 0 Reply Likes
Local Notification is the iOS term for a timed event that can awaken your application. I'm looking for the same thing (in any cross-platform tool). I want my app to be configurable for when or how often it pops up.
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Hey Tobin,

As I mentioned above you can get Banner notifications etc using the plugin provided above. (direct link: https://github.com/phonegap/phonegap-...)

PhoneGap Build does not provide these currently, however it's a likely candidate for the future.

Hardeep Shoker
Photo of Neil Alderson

Neil Alderson

  • 1 Post
  • 0 Reply Likes
Hi Hardeep,

I too am interested in this functionality as I need to build a cross platform app that can push local notifications after a time delay prompting the user to take action.

I'd love to just use PhoneGap Build where I call a common JavaScript function, much like navigator.notification.alert.

Since that isn't possible, can you explain to me how I can use the plugins you've mentioned to have one HTML/JS code base that can call the relevant plugin for each platform? If I suddenly have to maintain a different code base for each platform then PhoneGap kinda becomes unnecessary, I might as well develop native apps.

Neil Alderson
Photo of Stéphane Benchimol

Stéphane Benchimol

  • 1 Post
  • 0 Reply Likes
Hello,
Thank you very much for all those informations. I'm very interested finding a way to adress this problematic as well !
Did you find a soltion ?
Thanks,
Stéphane
Photo of Maria Jose Alvarez

Maria Jose Alvarez

  • 31 Posts
  • 0 Reply Likes
hi, i'm very interested in this theme, anybody could tell us when will it be available?
Photo of Matt Chatterley

Matt Chatterley

  • 24 Posts
  • 2 Reply Likes
Hi, is there any news as to whether this functionality will definitely feature in a future plugin or not?
Photo of cloudtraveler

cloudtraveler

  • 1 Post
  • 0 Reply Likes
Hello, is there any progress about local notifications? This is a very important feature. There is some old plugin project that works with some previous versions of PhoneGap. Yet, it would be really important to have this feature incorporated into PhoneGap.
Here is the plugin for old PhoneGap:
https://github.com/phonegap/phonegap-...
Photo of Matt Chatterley

Matt Chatterley

  • 24 Posts
  • 2 Reply Likes
About a month ago, a PGB representative commented on this thread - http://community.phonegap.com/nitobi/... - replying to one of my posts, stating that local notifications were being looked into / considered for the future.

However, there has been no reply over here and as far as I can see it isn't a priority for them, which is really odd to me as it's a pretty big hole in the system (and the only reason why we're looking into alternative frameworks)!
Photo of Matt Chatterley

Matt Chatterley

  • 24 Posts
  • 2 Reply Likes
(it's also frustrating that this topic is labelled as 'answered' when the only answer given is far above - 'use a plugin' - to which the riposte is - there isn't a plugin!)
Photo of Travis Boudreaux

Travis Boudreaux

  • 1 Post
  • 1 Reply Like
I agree with Matt.

This topic is answered, it's implied that this feature is coming, but there's no where to get a status update.

So, is this feature on the roadmap, and if so, what's the priority?
Photo of Matt Chatterley

Matt Chatterley

  • 24 Posts
  • 2 Reply Likes
Doubly frustrating - it seems that using push notifications and the generic push plugin, you can get notifications in the bar - however, there's no support for generating these locally!
Photo of Larry Richard Beltran Flores

Larry Richard Beltran Flores

  • 10 Posts
  • 0 Reply Likes
Hello every body, I have seem in:

https://build.phonegap.com/plugins/33

It is a plugin to local notifications, Do you know how to use it in phone gap build?
Any example?

In the config.xml I put:

In the index.html I put:

And in my button click metod:

alert("Manual01");
var d = new Date();
d = d.getTime() + 60*1000; //60 seconds from now
d = new Date(d);

alert("Manual02");
window.plugins.localNotification.add({
date: d, // your set date object
message: 'Hello world!',
repeat: 'weekly', // will fire every week on this day
badge: 0,
foreground:'foreground',
background:'background'
});
alert("Manual03");

The "alert" is to debuging when this run in device.

When I press the button, the app show:
"Manual01"
"Manual02"
but "Manual03" dont appear

Any idea?
Photo of Larry Richard Beltran Flores

Larry Richard Beltran Flores

  • 10 Posts
  • 0 Reply Likes
In the config.xml I put: ( I have erase some simbols to permit show)

plugins>
gap:plugin name="com.simplec.plugins.localnotification" />
/plugins>

In the index.html I put:

script type="text/javascript" charset="utf-8" src="cordova.localNotification.js" /script
Photo of vikas .s

vikas .s

  • 3 Posts
  • 0 Reply Likes
Bugged up,

Then is there any other solutions to use local notification,

I don wan to get back to native development,Since i have completed 3/4th of my application and wrapped up using phone gap build. Stuck up when came to local notification.

What for PG Build then.
Photo of ismael jimoh

ismael jimoh

  • 4116 Posts
  • 192 Reply Likes
Hi,

Please go to this link.

It's been updated and approved unfortunately still defaults to the old version though the latest supports 3.1

Ismael


Photo of vikas .s

vikas .s

  • 3 Posts
  • 0 Reply Likes
Hi ismael jimoh,

The documentation of that plugin says that it supports only ios, and also contains .h and .m files,

It doesnt supports PG Build. Any other solutions.
Photo of ismael jimoh

ismael jimoh

  • 4116 Posts
  • 192 Reply Likes
Hi Vikas,

All plugins listed within PhoneGap Build plugin page work with PhoneGap build.

Skip the above section jumping straight to the using the plugin section.

Ismael
(Edited)