Hey team,
I am using the iOS10 branch of the plugin and when I schedule a local notification and it triggers while I am in the foreground it is also showing an alert box.
Here's what I've tried:
Dug through all the code to see if I have any alerts (and I do not)
Removed all my other plugins and it still happens
Tried changing the settings for scheduling and it still shows
It's just an empty dialog box with my app's name in it.
Is anyone else experiencing this and if you've managed to resolve it how did you do that?
It's not an HTML alert box, its an IOS 10 Notification box. We see these on our app as well though ours have more information in them :)
Are you scheduling an IOS 10 notification with no text?
Rob.
Yes that is what I had discovered, was just making sure people knew it wasn't in my front end code.
My goal is to not have that alert box because it's absolutely useless in my context. I do have text and data that is getting sent though, which is the odd part.
Are you aware of a way to stop it from showing the dialog box?
What kind of notifications have you set in your system settings? Perhaps you have an alert box as opposed to a banner?
Rob
Nope I have it set to Banners. It's only an issue it seems on iOS 10 and the iOS 10 plugin branch but I can't seem to figure out in the native code how to prevent it from showing. I was assuming it would be a flag or somewhere in the creation of the new notification object but my search yielded no results
So when does this notification appear?
What are you doing that could trigger it, even if that trigger is apparently nothing to do with it? What are you scheduling at this time and what does the code look like?
We use IOS 10 notifications, we send silent notifications from servers, non-silent notifications from servers, local notifications, clear them out, reschedule them on almost a minute by minute basis and don't get this.
Rob
Yeah it really does seem strange, I've spent about 7 hours investigating which is why I came here haha.
I am scheduling them, they are part of a timer system. The user starts the timer and then can leave their phone to do whatever and be notified when the time is up, for context.
cordova.plugins.notification.local.schedule({
id: 1000,
at: scheduledTime, // This is calculated on the fly, on average 30 seconds+
text: details, // just a basic string of text
title: title, // normal title
badge: 0, // I've tried removing this, doesn't change anything
sound: audio, // audio link generated somewhere else
data: '{"type" : ' + type + ',"category" : "myCategory"}' // Some data I need
}, null, scope);
I've removed all my trigger handlers and it still behaves the same way, for the record.
If I let the notification run in the background, and then come to the app, it doesn't happen, it only happens when it fires and the app is in the foreground
My remote notifications behave totally fine as far as I've seen. It's only these local foreground ones
I assume that when you use the phrase "starts the timer" you're not relaying on a javscript timeout to fire?
The major differences between our code and yours is
We put everything we schedule in an array as we found it dodgy to work on objects. Even if its a single object, its still in an array.
We have a callback function to check things which shouldn't make any difference. You have null.
You are passing a string to the data: field which looks like a JSON but isn't. Can see that making a difference either.
We pass an empty string for sound.
We don't set the badge at all.
Its not clear what your scheduledTime is actually. We use
var now = d.getTime();
reminder0 = new Date(now + 5 * 1000);
for a notification five seconds from now. We've found problems setting notification at now
or in the past so we don't.
And thats it. Our notification setting code identical for IOS 8,9,10 and Android.
Sorry can't suggest anything else.
Rob
Correct, not a timeout fire
Welp, thanks for trying.
I'd check the version of the plugin you have then.
We have the same code and we don't get it.
I have, this isn't my first rodeo.
@north do you have an onTrigger handler? I use both an onClick and an onTrigger handler, and don’t get an iOS10 notification box when a notification fires while the app is in the foreground. I haven’t experimented to see what happens if I _don’t_ have an onTrigger handler but...
On Dec 11, 2016, at 1:47 PM, North McCormick notifications@github.com wrote:
I have, this isn't my first rodeo.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
I have the exactly same problem since I used another fork to get the plugin work on iOS 10 : https://github.com/EddyVerbruggen/cordova-plugin-local-notifications
@ludooo I tried that fork too, (not at the computer with the source) I had the same issue there too.
@Tawpie I have both, and I've removed both and it's the same behavior. Do you have the commit hash or the exact exact version of the plugin you have? I have the latest iOS10 branch as of yesterday, so maybe they changed something in a recent commit that you don't have
I’m very bad, I use a fork of my own devising (because I need to control what plugin I’m using) It’s here, NO GUARANTEES, it’s not up to date and I may mess with it…
On Dec 12, 2016, at 11:07 AM, North McCormick notifications@github.com wrote:
@ludooo I tried that fork too, (not at the computer with the source) I had the same issue there too.
@Tawpie I have both, and I've removed both and it's the same behavior. Do you have the commit hash or the exact exact version of the plugin you have? I have the latest iOS10 branch as of yesterday, so maybe they changed something in a recent commit that you don't have
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
Hahaha, I'll give it a try tonight, thanks
Did you find a fix for that ?
@ludooo I still have not found a fix :(
the following works on my ios10 and android6 device using the #ios10 branch:
var foo = new Date().getTime();
var now = new Date(foo + 5000).getTime();
var one = new Date(now + 1000),
two = new Date(now + 2000),
three = new Date(now + 3000);
var notifications = [
{
title: "One",
text: "Text",
at: one,
id: 991
},
{
title: "Two",
text: "Text",
at: two,
id: 992
},
{
title: "Three",
text: "Text",
at: three,
id: 993
}]
cordova.plugins.notification.local.schedule(notifications);
with the app in fg or bg.
[EDIT] using platforms:
[email protected]
[email protected]
@skotturi 'Works' as in, doesn't show the alert box when received in the foreground?
I was having this issue too... couldn't figure it out... and I've been having a bit of a hard time in general with notifications... however... I just rebuilt for iOS... and now they've gone.. and I've not actually done anything... I don't think (I'm using the ios10 branch)
I am using Notie with a trigger set to use that when it fires...possibly that? Let me know if you want me to give you any further info... (apologies if this is no use, just thought I'd let you know I feel your pain)
Turns out after updating my plugins One Signal had a bunch of breaking changes, so even though the One Signal plugin wasn't initializing it was still enforcing their notification defaults (which include the alert box) but there was no way to know it was that. I had just recreated the project to try and test it again and that's when I found out. It didn't have an effect the first time I tested it so be sure to try that.
If anyone is using one signal and has this issue, this is my new init code
window.plugins.OneSignal.startInit("your-id-here")
.inFocusDisplaying(window.plugins.OneSignal.OSInFocusDisplayOption.None)
.endInit();
Good to know what caused it.
I've used OneSignal and they have a pretty good system. We currently use PushWoosh but we keep our code up to date with OneSIgnal's SDK in case we do want to move. The main reason we don't uase them is we can't seem to clear their notifications through JavaScript and setbadge(0)/setBadge(1). We can't work it out but thats an issue for another forum.
@NorthMcCormick Thank you a lot man, the fix works perfectly !