Cordova-plugin-local-notifications: Broken in iOS10 beta?

Created on 6 Jul 2016  Â·  80Comments  Â·  Source: katzer/cordova-plugin-local-notifications

While the scheduling example for "5 seconds from now" works in the 9.3beta of iOS, it seems to break in the iOS10beta2. The success function fires, but no notification appears. Wonderful plugin, thank you a thousand times over!

Most helpful comment

Hey all, I've merged the PR #1093 into the iOS10 branch!

All 80 comments

The code this plugin uses is 100% deprecated in iOS 10. Any app built _for_ iOS 10, the notifications won't trigger. They need to use the new User Notifications API

Dear, iam using windows phone 8 not ios
On Jul 11, 2016 1:54 AM, "North McCormick" [email protected] wrote:

The code this plugin uses is 100% deprecated in iOS 10. Any app built
_for_ iOS 10, the notifications won't trigger. They need to use the new
User Notifications API

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/katzer/cordova-plugin-local-notifications/issues/1034#issuecomment-231618518,
or mute the thread
https://github.com/notifications/unsubscribe/ATcB_m6xVwCqIYVHT--mcnnOAkSx-J81ks5qUYY5gaJpZM4JGPvY
.

@MohamedFekry007 That is not relevant to this specific issue

Dear, ok sorry,

Could you check my issue please?
On Jul 11, 2016 1:57 AM, "North McCormick" [email protected] wrote:

@MohamedFekry007 https://github.com/MohamedFekry007 That is not
relevant to this specific issue

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/katzer/cordova-plugin-local-notifications/issues/1034#issuecomment-231618667,
or mute the thread
https://github.com/notifications/unsubscribe/ATcB_pHs7oV9KrvsfA1PpbAH4L9Nmpt2ks5qUYbZgaJpZM4JGPvY
.

@MohamedFekry007 No, I only work with iOS, sorry.

Ok thanks
On Jul 11, 2016 1:59 AM, "North McCormick" [email protected] wrote:

@MohamedFekry007 https://github.com/MohamedFekry007 No, I only work
with iOS, sorry.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/katzer/cordova-plugin-local-notifications/issues/1034#issuecomment-231618803,
or mute the thread
https://github.com/notifications/unsubscribe/ATcB_mzN3UMt-xgYGy8zdnogBC2D0chQks5qUYdlgaJpZM4JGPvY
.

@NorthMcCormick Thank you so much for replying. What would you recommend as a solution for local notifications in iOS10 (for a cordova based app)? Are you available for hire / interested in coding a solution?

Dear, of course why not
On Jul 11, 2016 4:57 AM, "Christopher CInq-Mars Jarvis" <
[email protected]> wrote:

@NorthMcCormick https://github.com/NorthMcCormick Thank you so much for
replying. What would you recommend as a solution for local notifications in
iOS10 (for a cordova based app)? Are you available for hire / interested in
coding a solution?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/katzer/cordova-plugin-local-notifications/issues/1034#issuecomment-231632006,
or mute the thread
https://github.com/notifications/unsubscribe/ATcB_uWTh6EKGPOtS-cNQt6EGIqgmbhyks5qUbE3gaJpZM4JGPvY
.

jokiamo what's the status on your fork? Is it working on ios 10 prerelease?

i tested on beta2 and work!

@jokiamo Are you open to PRs for more features with the new notifications?

yes

@jokiamo you are the best!! Can't wait to test your code. Incredibly grateful.

@jokiamo Well done my friend.

@jokiamo Works brilliantly! Thank you so so so much!

Hey -- appears I jumped the gun slightly - while notifications appear, they don't seem to go off at the proper time. If I schedule a notification for an hour from now, the notification appears almost instantly, within a minute or so. Seems like great progress though!

jokiamo solution does not work for me, for example it does not trigger events....
My solution is only change APPLocalNotificationOptions.m (original plugin), only replace NSCalendarUnitEra by 0, I do not know if this change can induce other problems, but at the moment it works ok.

(line 151)

  • (NSCalendarUnit) repeatInterval
    {
    NSString* interval = [dict objectForKey:@"every"];

if ([self stringIsNullOrEmpty:interval]) {
return 0;
}
else if ([interval isEqualToString:@"second"]) {
return NSCalendarUnitSecond;
}
else if ([interval isEqualToString:@"minute"]) {
return NSCalendarUnitMinute;
}
else if ([interval isEqualToString:@"hour"]) {
return NSCalendarUnitHour;
}
else if ([interval isEqualToString:@"day"]) {
return NSCalendarUnitDay;
}
else if ([interval isEqualToString:@"week"]) {
return NSCalendarUnitWeekOfYear;
}
else if ([interval isEqualToString:@"month"]) {
return NSCalendarUnitMonth;
}
else if ([interval isEqualToString:@"quarter"]) {
return NSCalendarUnitQuarter;
}
else if ([interval isEqualToString:@"year"]) {
return NSCalendarUnitYear;
}

return 0;
}

I have changed the method too,

  • (BOOL) stringIsNullOrEmpty:(NSString*)str
    {
    if ([str length] == 0)
    return YES;

return NO;
}

a couple of notes: the repo referenced above hardcodes a test notification to fire in 5 seconds, more work is needed to add full plugin functionality. There's an earlier and slightly more complete example of how to do this at https://github.com/ChenYilong/iOS10AdaptationTips

second: I found I needed to include the NotificationCenter.framework in my Xcode Linked Frameworks and Libraries else it wouldn't compile (duh)

also: the example repos use the @import directive, you must enable modules in your Xcode project (Build Settings, search for 'modules', then Enable Modules (C and Objective-C) on)

In my experiments (Xcode8b5 and ios10b5) trying to grab the plugin's fireDate and rejigger it for the new framework, I could get a notification to schedule without reporting an error but it didn't fire. Then without explanation my app wouldn't run anymore. I'm chalking that up to beta-ville, but it ran once and after that single run it can't get past the splash screen. Ugh.

@katzer I hope you're nearly finished with those other two plugins!

Have you tested my solution? In my application it is working fine.

I have not... mostly because by reading it I didn’t understand how you solved the deprecated API issue. It is however, possible that Apple won’t be making the old API go away immediately and that your fix solves another issue—so I’ll try it. If I can get the dang thing to work in Xcode8b5 on iOS10b5 that is. Q: what prompted you to approach the problem this way?

On Aug 12, 2016, at 4:34 PM, malloc32 [email protected] wrote:

Have you tested my solution? In my application it is working fine.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@malloc32 I tried your solution today (file changes to -original- plugin, still uses the deprecated API), did not get notification to fire on iOS10b6 (iPhone5). Built in Xcode7.3(7D175), delivered to iPhone via TestFlight.

Yes,it uses the deprecated api, I m only be able to do small changes,not iOS native programing...but it is working on an iPad,now I can not tell you the beta versión, but it works...

@malloc32 I tried the code with the same specs as @Tawpie and was also unable to get it working. The GM has got to be dropping soon, - it would be ideal to have a solution before then so we can update our projects in time for the official release. If I knew objective-c I'd try to contribute myself -- hopefully someone or @katzer will find a solution soon. If there is anything productive I can do to help I'd very much like to.

Hey @jokiamo ! Tried your fork on iOS10 GM but it does not seem to work. It is an awesome plugin and it will great to have it working with iOS 10. Does anybody else has got it working as yet?

And, @malloc32 , tried your changes on iOS 10 GM. While notifications are scheduled and triggered, they are not shown.

I can confirm @mkn20 - I tried as well.

iOS10 releases publicly in 5 days.... this situation is getting somewhat desperate for me, as local notifications are essential to our non-profit safety app and iOS10 renders it unusable. Would it be possible for me to hire someone to get it working? @katzer do you have any ideas? Thank you.

i quote @ccj242 @katzer. Can you tell us if you are developing a new version? thank you

I'm going to post a job on some freelance sites and get a quote for how much it would be to get this working - @katzer please tell me if this is a waste of time and money. Would anyone connected to this thread be interested in doing this as a work for hire? @NorthMcCormick? Please excuse me if I come off as pestering, but as I develop a non-profit safety app, the ability to notify the user is literally critical. Thank you for your help and understanding!

@ccj242 like you local notification capability in iOS v10 is essential to my app. Happy to contribute to any development work if you had any joy? @katzer ??

I would happily contribute in paying a freelancer if it comes to that... question is, is @katzer available to check a PR and make a release anytime soon?

I'm also happy to contribute.

Thanks @gmcdowell, @perrin4869,@lync0056! I have some freelancers lined up, but I'd like to wait to hear back from @katzer before I pull the trigger.... I emailed him about a month ago and he assured me he was working on it. It would be a shame if he's on the cusp of releasing this update and I pursue this needlessly.... If we don't hear back from tomorrow I guess I'll go ahead and start a contract.

PR #1093 just published, might be what we've been looking for!

Great. That said, on a quick test it doesn't seem to work for me. Does anybody else try and can share the results?

I didn’t test this PR but looking at the PR it ultimately incorporates the same code as ChenYilong (and jokiamo) published, complete with hardcoding a notification 5 seconds in the future. The ChenYilong/jokiamo code did fail for me, and I don’t see anything in this PR that raises my hopes.

@katzer! Wo bist sie

On Sep 12, 2016, at 6:18 AM, mkn20 [email protected] wrote:

Great. That said, on a quick test it doesn't seem to work for me. Does anybody else try and can share the results?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

The PR shouldn't be merged if it's hard coded to 5 seconds, that's dangerous if it gets merged.

I might have some time today or tomorrow to continue looking at the code, I'm not an expert but I can keep trying. I am also willing to pitch in for a free lancer if that happens

That PR will also trigger a notification whenever you schedule, update, cancel, or cancelAll notifications because it's using fireEvent without checking what event is firing.

Unfortunately half the functionality of this plugin is implement as an extension to UILocalNotification which is now a deprecated class.

PR #1093 doesn't work for me either -- should I go ahead with a freelancer? @jokiamo, @spk0611, @ChenYilong - anyone confident/interested?

@Tawpie, @NorthMcCormick the hardcode for 5 seconds is already removed.
@mkn20, @dpogue Can you please share the scenario in which this is failing? I'll try to fix them as soon as possible and update the CR.

@spk0611 Thank you for your attention to this, we really appreciate it. Please let me know if there's anything at all I can do to help and let me know the moment you feel stuck so I can proceed with a freelance contract.

@ccj242 @mkn20 , Can you please also confirm your ios beta version? I tried on 10.0.0 and the notifications didn't work for me. Interestingly, native reminders app also didn't show any notification for that version. I recently updated to GM Seed version then and it's started to work fine now.

I've been using GM as soon as it was released.

Same here.

@spk0611 - we've been experiencing same behavior with iOS10, iOS Reminder app started displaying notifications once we moved to GM Seed.

GM Seed still isn't giving me notifications. I'll keep trying.

UILocalNotificaton is deprecated as of iOS 10 so it's still okay to use until probably iOS 11.

@spk0611 You are truly a god among men. Your updated PR #1093 works flawlessly for me so far in my testing. I would like to test it more rigorously tomorrow but so far so good! I am truly in your debt!

@ccj242 Good to know that it's working for you now. However you said yesterday that it wasn't working. Can you please let me know if anything had to be done differently for this to work?

Also, in iOS 10, local notifications aren't shown in notification centre when app is in foreground. For this, you can listen to 'trigger' event in your app, if you want to handle it. Here's the sample code for that which I'm using in my project.

       if (ionic.Platform.platform() === 'ios' && ionic.Platform.version() >= 10) {
          cordova.plugins.notification.local.on('trigger', function (notification) {
            if (!$rootScope.appInBackground && alertHandlerService && alertHandlerService.alert) {
              // how do you want to handle it in app
            }
          });
        }

After the new commit he made to #1093: "iOS 10 - all events fired as other iOS versions" notifications seem to be functioning as expected. And yes, @sparsh0611 I did notice that, thank you for this sample code!

@malloc32 I try your fix and in my application working fine. In iOS 10 and in iOS 9.x. and builded with xCode 7.3
When @katzer release new plugin version I update it.

embarrassing github noob question: I haven’t tried to test code that’s part of a pull request before… anyone willing to give me hints on how to get it so I can test? Going to the repo at spk0611 and adding the plugin directly from there errors out during build.

Thx!

On Sep 13, 2016, at 1:31 AM, Christopher CInq-Mars Jarvis [email protected] wrote:

After the new commit he made to #1093 https://github.com/katzer/cordova-plugin-local-notifications/pull/1093: "iOS 10 - all events fired as other iOS versions" notifications seem to be functioning as expected. And yes, @sparsh0611 https://github.com/sparsh0611 I did notice that, thank you for this sample code!

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/katzer/cordova-plugin-local-notifications/issues/1034#issuecomment-246612372, or mute the thread https://github.com/notifications/unsubscribe-auth/AHVytPt6tUmj5vMDfo_KeGWuQ4-KOzMdks5qpl9dgaJpZM4JGPvY.

@Tawpie you'll just have to remove the existing plugin and add this plugin by running this command.

ionic plugin add https://github.com/spk0611/cordova-plugin-local-notifications.git

Can you please check your current cordova versions? The versions that I have are
cordova 6.0.0
cordova-ios 4.1.0
cordova-android 5.1.1

Also, please make sure to build it from XCode 8 GM, and not XCode 7.

Works well for me here on Xcode 8 && iOS10, but I have only required it to fire a local notification straight away.

thanks @spk0611, have tried that but it fails to build on Cordova. Details:
node: v5.9.1
npm: v3.8.9
Cordova: v6.3.1
Cordova iOS platform: v4.2.1 (and 3.9.1)
Xcode 8GM

Builds fine with the ‘stock’ Katzer plugin though.

Error message:
The following build commands failed:
CompileC build/SmartQuit.build/Debug-iphonesimulator/SmartQuit.build/Objects-normal/x86_64/APPLocalNotification.o SmartQuit/Plugins/de.appplant.cordova.plugin.local-notification/APPLocalNotification.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

So I’m stumped.

On Sep 13, 2016, at 7:06 AM, spk0611 [email protected] wrote:

plugin add https://github.com/spk0611/cordova-plugin-local-notifications.git https://github.com/spk0611/cordova-plugin-local-notifications.git

@Tawpie I got it working with:

cordova plugin rm de.appplant.cordova.plugin.local-notification --save
cordova plugin add https://github.com/spk0611/cordova-plugin-local-notifications#9ad32cf2059cdf9a54b4930b1c58ba76ef7e3a87 --save

That adds the plugin at the specific commit referenced above where "iOS 10 - all events fired as other iOS versions" was added as noted by @ccj242

@Tawpie can you please go to XCode -> Preferences -> Locations and check if Command Line Tools is set to XCode 8 for you? Or is it set to XCode 7?

Thank you @spk0611. On a quick test it seems to work in ios 10 GM. I'm scheduling multiple notifications at different dates and times and, for some reason, it fires only the first but somehow not the later ones. I'm using cordova ios 4.1.0. @acianti it is interesting. Does it work okay for you with @malloc32 's change on both iOS 9 and iOS 10?

ah. 7.3. Resetting to 8, although I was able to get it to build using the sequence provided by @cookiecookson. next step: test! (yay, finally—will be testing with command line tools set to 8) Thank you all!

On Sep 13, 2016, at 8:41 AM, spk0611 [email protected] wrote:

@Tawpie https://github.com/Tawpie can you please go to XCode -> Preferences -> Locations and check if Command Line Tools is set to XCode 8 for you? Or is it set to XCode 7?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/katzer/cordova-plugin-local-notifications/issues/1034#issuecomment-246724954, or mute the thread https://github.com/notifications/unsubscribe-auth/AHVytGBpZCUO2yvgm67zasUg6SnDe5Xtks5qpsRHgaJpZM4JGPvY.

I think I'm seeing the trigger is not being fired in my case when my future date is in different timezone. For instance, if device is in PDT timezone, the scheduled notifications, as long as device timezone is still the same for the dates, seem to work fine. But when the timezone changes, say to PST, which has 1 hour difference from PDT, scheduled notification are not fired. Is there then a way to schedule a notification for PST, while the device is still in PDT, so that notification is fired in future at the correct time in future when the device timezone changes from PDT to PST? Hopefully it makes sense!

Any ideas in that regard?

@spk0611 Been fighting with this all afternoon, but when I use your repo everything will (finally) build, but cordova.plugins.notification is undefined. Stock Katzer is fine though. Any clues for me? (Thanks)

A couple of notes while I wait to see if the notification will fire...
1) be certain to add the UserNotifications.framework to your target
2) be certain to "Enable Modules (C and Objective-C)" in Build Settings (search for modules)

Otherwise cordova/Xcode will crash when you attempt to build.

I also left in the cordova-plugman engine definition in plugin.xml (it was commented out in one of Katzer's commits) as that "seems" to be the key to not losing cordova.plugins.notification. I didn't do the back and forth to be certain, but with that definition left in I regain access to the plugin.

AND. Victory! A date and time based notification just fired and tapping it launches my app. No sound oddly, but it's a start.

MANY, many thanks to all of you! (now we build for testflight and see what new surprises Apple has in store there eh?)

Hi all, sorry I haven't yet had the time to look into it. Even the update for the background-mode plugin is paused as I don't know what to do first... It looks like to support iOS10 it will need more that just a hot fix. Damn Apple...

Again, @spk0611's PR #1093 works for me on iOS10GM - with the caveat that @sparsh0611 mentioned. My issues have been resolved for the time being, thank you all! Shall I keep the issue open as a courtesy to others?

It's not safe to blindly schedule in the fireEvent function without checking what type of event was fired. That function is called for schedule, update, cancel, cancelall, clear, clearall, trigger, and click.

For me, I'm getting some inconsistent results when using the released iOS 10. I'm scheduling multiple notifications at different dates and times in future (by passing them as an array to the schedule method for the plugin) and, for some reason, it fires only some of them but not all. On the other hand, all are fired just fine when using iOS 9. Not sure what I'm missing.

To echo @mkn20, I have noticed some inconsistent results as well compared to iOS9 - I can't identify any pattern to them - they seem random. Still, grateful to have something half working for iOS10 rather than not at all.

@spk0611's PR seems to be working (https://github.com/katzer/cordova-plugin-local-notifications/pull/1093) for me too. For context:

I'm scheduling a notification ~1-5 minutes ahead at a time.

@ccj242 Looking at the issues others (and you) are facing, I don't think this issue should be closed for now.
@mkn20 @dpogue Thanks for letting me know. I'll try to identify the issues and work on fixing them.
It's working so far in the scope that I require it for. But, I think it'll be better if it's more stable. So, if there's someone who can help in fixing the issues, it'll be really appreciated.

+1 Working but not as stable as it used to work prior to iOS 10.

@katzer i understand it will take time to fix this damn ios10 update properly but is there anyway to commit a half patch commit on master branch ? (to satisfy a part of the plugin users and let them wait a few days more to the final fix) ?
Your plugin seems the only one to be working for local notification on android and ios and if we could avoid using temp branches, it should be great and better for all (at least for test and issues report purposes)

@lucbonnin I agree, if you didn't see this and need it in the mean time (or anyone else who needs to use the plugin patch, here is how to do that): https://github.com/katzer/cordova-plugin-local-notifications/pull/1093#issuecomment-247429360

Hey all, I've merged the PR #1093 into the iOS10 branch!

Hello everyone, will iOS10 branch be merged to the master branch sometime?

I am working on it already. I haven't yet done any commits but the new version will not be compatible anymore with iOS 9 because of the new UserNotifications API.

I've updated the ios10 branch. It supports both iOS9+iOS10. Its still a work in progress but most things do work. It does not yet contain any new features provided by the new SDK.

Thank you @katzer it was not a breaking one for me, but I followed this bug and I really want to take a moment to give thanks for the work done.

@katzer thank you for making this plugin, I'm attempting to use the ios10 branch in my application, but I'm getting really inconsistent results when attempt to schedule multiple notifications. For example, when I schedule 8 notifications, 2 minutes apart (just so i can test that the delayed notifications work) I will get the first notification, but then none of the others. I was wondering if these issues were going to be resolved anytime soon, since it appears this has been an issue for the past 4-5 months already. I was hoping to use this plugin in my application because my needs for notifications aren't that large, but if scheduling notifications for the future just doesn't work at all, then I would need to use push notifications since this is the only local notifications plugin.

Please use 0.9-beta - thanks

Was this page helpful?
0 / 5 - 0 ratings