- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello I think the bigger pain in HTML5 compared to native development are the notifications! Definitively working with notifications I think the best recomendation is still continue in native. I am stuck here many time and would apreciate any help if someone has been able to achieve it with the HTML5 Cordova avaiable tools.
I am trying to set a local notification which has to appear every 100 minutes. For this the best thing I found is this plugin: https://github.com/katzer/cordova-plugin-local-notifications
But it is unfinished and I think it is not working properly but currently I think there are nothing better. I try set notification with this code:
info1=time1.getHours()+":"+time1.getMinutes();
cordova.plugins.notification.local.schedule({
id: 1,
title: "Notification!",
text: message,
firstAt: time1,
data: info1,
every: 100
});
The problem is that the every parameter is not working, the notification appears only the first time, all the other parameters are working fine. I asked in plugin page https://github.com/katzer/cordova-plugin-local-notifications/issues/509 ; in stackoverflow too but not answer.
If someone had experience with this plugin or can recommed another tool I would be really grateful.
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I recommend reviewing the required object structure for the cordova.plugins.notification.local.schedule(<object>) function. For example,
cordova.plugins.notification.local.schedule({
id: 1,
text: 'My first notification',
sound: isAndroid ? 'file://sound.mp3' : 'file://beep.caf',
every: 'day',
firstAt: next_monday,
data: { key:'value' }
})
Your provided code doesn't include the proper value for data.
Also, review the CHANGELOG and appropriate versions at https://github.com/katzer/cordova-plugin-local-notifications/blob/master/CHANGELOG.md
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The one you've used is the most cross-platform. Check this out : https://github.com/javamrright/cordova-plugin-local-notifications/, they've forked from the the one you've used and fixed some bugs. And if you want iOS only then this one might work: https://github.com/GotCakes/Phonegap-LocalNotification/
Swati
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Elroy thank you very much for your help! In last version it is possible to use directly a string but just in case i tried with this sample code:
var now = new Date().getTime(),
_60_seconds_from_now = new Date(now + 60*1000);
cordova.plugins.notification.local.schedule({
id: 1,
title: "Notification!",
text: "message",
firstAt: _60_seconds_from_now,
every: 100
});
Unfortunately the behaviour is the same, I get only the first notification in 1 minute, but I am not receiving any notification after 100 minutes. I think it is a problem with the every parameter in plugin or maybe there are some limitation in android because all other its working fine. Its strange because if I set the every to 5 it works about the first 5 or 6 times(it varies) and stops notifying later. I mean using this code:
var now = new Date().getTime(),
_60_seconds_from_now = new Date(now + 60*1000);
cordova.plugins.notification.local.schedule({
id: 1,
title: "Notification!",
text: "message",
firstAt: _60_seconds_from_now,
every: 5
});
The notification is recived in 1 minute and after that every 5 minutes but only 5 times.
Thank you for your sugestion Swati!, yes I think the only solution is to find another plugin but currently I think there are nothing better that this from Katzer. With this other one its very weird, instead of receive the first notification (after 1 minute) I receive an android popup saying that the app has ended, and nothing more after 100 minutes. I am using just the sample code with a repetition:
var now = new Date().getTime(),
_60_seconds_from_now = new Date(now + 60*1000);
window.plugin.notification.local.add({
id: 1,
title: "Join raid!",
message: "nombreraid",
repeat: 100,
date: _60_seconds_from_now
});
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page