katzer / cordova-plugin-local-notifications

Cordova Local-Notification Plugin
Apache License 2.0
2.56k stars 1.74k forks source link

iOS 10 notification problem #1096

Closed acianti closed 6 years ago

acianti commented 7 years ago

Dear @katzer, we are using your plugin in hybrid app for a very important costumer and we have a problem with notification in iOS 10 GM using version 0.8.4. The issues is not display the notification in iPhone devices. Waiting for your new release that patch this issue I modified then plugin, following the indication present in the issues #1034. I've created a new fork here: https://github.com/acianti/cordova-plugin-local-notifications, please refer to this to find details of modification done. Can you please implement as soon as possible the above fix in the new version of plugin. Can you also please inform about possible date in which new plugin would be avaible? Many thanks in advance for your support! Best regards, Andrea

sumedh-plenarea commented 7 years ago

Even I am facing the same issue. I am using Ionic and notifications are not getting scheduled for iOS 10. Do i need to use the new fork temporarily https://github.com/acianti/cordova-plugin-local-notification.?

gaurangpatel commented 7 years ago

I too facing same issue, working on ionic App with local notification.

any workaround to use deprecated UILocation or update in the plugin itself?

spk0611 commented 7 years ago

@sumedh908 @gaurangpatel I have fixed the issue on iOS 10 and created the PR - #1093 Please have a look and let me know if that works.

gaurangpatel commented 7 years ago

Thanks @spk0611 ,

I changed the file APPLocalNotification.h and added framework 'UserNotifications', I am getting notification when exit from region but not at enter region.

Do I need to make any other changes besides these two?

May be issues is related to delay or execution time but not sure.

JLNNN commented 7 years ago

👍 +1

lucbonnin commented 7 years ago

@katzer any chance to have a clean release for ios 10 ? As a ionic user i'm really blocked outthere :(

smuaq commented 7 years ago

Any updates on release on IOS 10?

timelight commented 7 years ago

I could find the fix in the ios branch and it seems to work well.

cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications#ios10

anuradhawick commented 7 years ago

@timelight does this work well on android as well?

sKuD51 commented 7 years ago

Hi,

I've updating my plugin but it doesn't work. I do this : $timeout(function(){ cordova.plugins.notification.local.schedule({ title: "New Message", message: "Hi, are you ready? We are waiting." }); alert('timeout'); },5000); I send just one notification after 5s app started. What's wrong ? I'm using #ios10 update. Thx !!!

sKuD51 commented 7 years ago

Sorry but it doesn't work for me. I don't know why. Here, my plugins list : com.unarin.cordova.beacon 3.4.0 "Proximity Beacon Plugin" cordova-plugin-app-event 1.2.0 "Application Events" cordova-plugin-compat 1.0.0 "Compat" cordova-plugin-device 1.1.3 "Device" cordova-plugin-whitelist 1.3.0 "Whitelist" de.appplant.cordova.plugin.local-notification 0.8.4.1 "LocalNotification" -> downloaded from https://github.com/Telerik-Verified-Plugins/LocalNotification.git My app authorize Notification and I just send a test, there is nothing else. Any idea ? Thanks a lot .

sKuD51 commented 7 years ago

@timelight it works for you ? do you have any example ? Thx.

ddennis commented 7 years ago

Hi i tried the version reference above by EddyVerbruggen, which hasent been merged yet. It works in my ionic app.

sKuD51 commented 7 years ago

@ddennis do you have a sample code ? I can find the solution, it works on iOS9 but not on iOS10. It's incredible !! Thx

ddennis commented 7 years ago

@sKuD51 I removed the current version with:

cordova plugin rm add de.appplant.cordova.plugin.local-notification

And install the telerik version from github:

cordova plugin add https://github.com/Telerik-Verified-Plugins/LocalNotification
sKuD51 commented 7 years ago

@ddennis that's I've did :-( I'm using cordova 6.1.1, cordova ios 4.1.2 and xcode 8.0

ddennis commented 7 years ago

@sKuD51 maybe the problem is in your client code

sKuD51 commented 7 years ago

@ddennis Maybe, but I can understand why it works fine on iOS 9 and not on iOS10. I've the prompt windows and I click Allow, but that's all, I've no notification. Thx.

Tawpie commented 7 years ago

@sKuD51: be sure to include a string id
 id: ‘Testing’ or something similar as well as specify the you want the reminder to fire (the ‘at:’ option). Your code sample doesn’t reflect correct use of the API for the plugin. Here’s where you can find more information: https://github.com/katzer/cordova-plugin-local-notifications/wiki/04.-Scheduling https://github.com/katzer/cordova-plugin-local-notifications/wiki/04.-Scheduling

On Oct 3, 2016, at 8:36 AM, sKuD51 notifications@github.com wrote:

Hi,

I've updating my plugin but it doesn't work. I do this : $timeout(function(){ cordova.plugins.notification.local.schedule({ title: "New Message", message: "Hi, are you ready? We are waiting." }); alert('timeout'); },5000); I send just one notification after 5s app started. What's wrong ? I'm using #ios10 update. Thx !!!

— 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/1096#issuecomment-251140055, or mute the thread https://github.com/notifications/unsubscribe-auth/AHVytHsWvfvBr76fRmK8YT_F3FN47V67ks5qwSDlgaJpZM4J8ec0.

sKuD51 commented 7 years ago

So, I create a new simple project app : cordova create test2 com.test1.app test2 with cordova 6.1.1 and just add plugin : cordova plugin add https://github.com/acianti/cordova-plugin-local-notifications Next, I add iOS platform : cordova platform add ios Here are my logs : `Adding ios project... iOS project created with cordova-ios@4.1.1 Installing "de.appplant.cordova.plugin.local-notification" for ios Fetching plugin "cordova-plugin-device" via npm Installing "cordova-plugin-device" for ios Fetching plugin "cordova-plugin-app-event" via npm Installing "cordova-plugin-app-event" for ios

    Your support is needed. If you use the local-notification plugin please support us in order to ensure further development.
    https://github.com/katzer/cordova-plugin-local-notifications#supporting

    Thank you!

Discovered plugin "cordova-plugin-whitelist" in config.xml. Installing to the project Fetching plugin "cordova-plugin-whitelist@1" via npm Installing "cordova-plugin-whitelist" for ios Finally, I just add a simple notification in index.js in deviceready event : onDeviceReady: function() { alert('ready to go'); cordova.plugins.notification.local.schedule({ id: 1, text: "Single Notification", sound: isAndroid ? 'file://sound.mp3' : 'file://beep.caf' }); app.receivedEvent('deviceready'); },` And I run : cordova run ios I see alert, prompt window, I allow notification, but there is no notification in list. How can I do more simple like this ?

Tawpie commented 7 years ago

you still need to tell it when to fire the notification (the at: option)
 like at: new Date(new Date().getTime() + 10000) And the id: MUST be a string, not an int.

On Oct 4, 2016, at 7:51 AM, sKuD51 notifications@github.com wrote:

So, I create a new simple project app : cordova create test2 com.test1.app test2 with cordova 6.1.1 and just add plugin : cordova plugin add https://github.com/acianti/cordova-plugin-local-notifications https://github.com/acianti/cordova-plugin-local-notifications Next, I add iOS platform : cordova platform add ios Here are my logs : `Adding ios project... iOS project created with cordova-ios@4.1.1 Installing "de.appplant.cordova.plugin.local-notification" for ios Fetching plugin "cordova-plugin-device" via npm Installing "cordova-plugin-device" for ios Fetching plugin "cordova-plugin-app-event" via npm Installing "cordova-plugin-app-event" for ios

Your support is needed. If you use the local-notification plugin please support us in order to ensure further development.
https://github.com/katzer/cordova-plugin-local-notifications#supporting

Thank you!

Discovered plugin "cordova-plugin-whitelist" in config.xml. Installing to the project Fetching plugin "cordova-plugin-whitelist@1" via npm Installing "cordova-plugin-whitelist" for ios Finally, I just add a simple notification in index.js in deviceready event : onDeviceReady: function() { alert('ready to go'); cordova.plugins.notification.local.schedule({ id: 1, text: "Single Notification", sound: isAndroid ? 'file://sound.mp3' : 'file://beep.caf' }); app.receivedEvent('deviceready'); },` And I run : cordova run ios I see alert, prompt window, I allow notification, but there is no notification in list. How can I do more simple like this ?

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

sKuD51 commented 7 years ago

@Tawpie I never used "at option", because I send notification on click (for example). And I've tried with String id => nothing . I'm going crazy !!!

Tawpie commented 7 years ago

@sKuD51 I think that you’ll still need to specify at: because if you don’t provide a fire date/time the phone does not know when to trigger the notification.

Be sure to set the fire date far enough in the future so that the fire date doesn’t happen before the software has a chance to complete the actual scheduling with the phone’s operating system. Notifications scheduled in the past won’t fire. Scheduling a notification to fire a second or two into the future should be fairly immediate for the user.

Curious though, if you’re wanting to alert the user on-click, is it necessary to use the local notification mechanism?

On Oct 4, 2016, at 8:12 AM, sKuD51 notifications@github.com wrote:

@Tawpie https://github.com/Tawpie I never used "at option", because I send notification on click (for example). And I've tried with String id => nothing . I'm going crazy !!!

— 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/1096#issuecomment-251418076, or mute the thread https://github.com/notifications/unsubscribe-auth/AHVytK856HNivcRdxWWRKjvys50hNv8Sks5qwmz6gaJpZM4J8ec0.

sKuD51 commented 7 years ago

@Tawpie In my app, I'm using notification with ibeacon plugin. When app is in background mode and user enter in a ibeacon region, app send a notification with ibeacon's enter message. This method worked very fine in iOS 9, 8, 7 ... and I repeat, I never used 'at' option, because I send notification in 'live' . So, I don't understand the problem. I thank you for yours advices.

Tawpie commented 7 years ago

I understand—that’s an entirely different use case than what I use. But if you can stand a delay of a second or two, you could try setting an at: time a couple seconds into the future.

I’m not sure of all the changes Apple made in iOS10, but something they did broke the way this plugin worked. Which tells me that in the OS something has changed, so what worked on iOS 7-9 may now be broken.

Good luck!

On Oct 4, 2016, at 8:46 AM, sKuD51 notifications@github.com wrote:

@Tawpie https://github.com/Tawpie In my app, I'm using notification with ibeacon plugin. When app is in background mode and user enter in a ibeacon region, app send a notification with ibeacon's enter message. This method worked very fine in iOS 9, 8, 7 ... and I repeat, I never used 'at' option, because I send notification in 'live' . So, I don't understand the problem. I thank you for yours advices.

— 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/1096#issuecomment-251428146, or mute the thread https://github.com/notifications/unsubscribe-auth/AHVytAJrOuILzAFI_wHuoUMZQStGHRoXks5qwnTxgaJpZM4J8ec0.

sKuD51 commented 7 years ago

@Tawpie Thanks. iOS10 is really a p... of ch.. there are so many changes and some plugins doesn't work.

lucbonnin commented 7 years ago

FYI, the notification is working on the ios simulator (only in background mode, so get back to device home) but not on a real device :( It is driving me crazy !


 cordova.plugins.notification.local.schedule({
            id: 'ID-'+Date.now(),
            at: new Date(new Date().getTime() + 10000),// now + 1s
            title: 'TEST',
            text: 'TEST content',
            badge: 666
        });
sKuD51 commented 7 years ago

@lucbonnin I confirmed, notification is only displayed when app is in background, and I tested my app on real device, that's run. And I confirm again, in my app, I use this plugin like this : cordova.plugins.notification.local.schedule({ id : i, title : "My title", text : "My message", badge : i }); Where i is an integer that I increment if app displays more than one notification. In other way, If found this example : https://swifting.io/blog/2016/08/22/23-notifications-in-ios-10/ but I don't know if we could adapt-it in this plugin. @katzer ?

cquezpro commented 7 years ago

can you help me for this? I didn't get working plugin yet. cordova.plugins.notification.local.registerPermission(function(str) { console.log('Push Permissions:'+str); setTimeout(function () { cordova.plugins.notification.local.schedule({ id: 10, title: "yo test in 15 minutes!", text: "test test test", badge: 1, data: { yo_payload:"yo data" } }); }, 1000); });

I got console.log('Push Permissions:'+str); but notification is not working.

sKuD51 commented 7 years ago

@sirius2013 Did you test in background mode ? juste click on home button and wait for notification.

cquezpro commented 7 years ago

yes, it worked.

cquezpro commented 7 years ago

worked when app is inactive.

sKuD51 commented 7 years ago

@sirius2013 Ok, it's the normal result from this plugin. I think it doesn't work in foreground ...

ammichael commented 7 years ago

I also have this problem. I've tried changing forks, but no lucky.

It is seriously worrying how the main repo of a really useful cordova plugin is having this kind of problems. I mean, it's not katzer's fault; he did more than I've done already, and took all of us here, but it worries me about hybrid apps.

Edit:

Guys, I've managed to get it working by removing the notification plugin along with "cordova-plugin-app-event", "cordova-plugin-badge", and adding acianti's fork (https://github.com/acianti/cordova-plugin-local-notifications).

The only problem I still have is not having actions (which I did, through a fork).

jmcrthrs commented 7 years ago

iOS9

Foreground:

Didn't show notification overlay Notification appeared in Notification centre

Background:

Shows notification overlay Notification appeared in Notification centre

iOS10

Foreground:

Didn't show notification overlay Notification doesn't appeared in Notification centre

Background:

Shows notification overlay Notification appeared in Notification centre

Looks like UNUserNotificationCenterDelegate needs to be implemented if we want the notification to appear at all when the app is running in the foreground.

https://github.com/katzer/cordova-plugin-local-notifications/issues/1084#issuecomment-249214914

Starting in iOS 10, you can now actually display the notification when the app is in the foreground by using the appropriate arguments in the completion handler in the UNUserNotificationCenterDelegate

https://developer.apple.com/reference/usernotifications/unusernotificationcenterdelegate/1649518-usernotificationcenter?language=objc

cquezpro commented 7 years ago

I will wait for plugin update have foreground working feature on iOS like android.

droolingOnU88 commented 7 years ago

I got it working on iOS10 with

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

shivam5x commented 7 years ago

Hi, Anything for foreground ?

Thanks

spk0611 commented 7 years ago

@shivam5x You can show alert inside app when in foreground. Currently, it isn't showing in notification centre for iOS 10, when app is in foreground.

cordova.plugins.notification.local.on('trigger', function (notification) {
    // show alert here
})
droolingOnU88 commented 7 years ago

@shivam5x no foreground...

rodrigodvp commented 7 years ago

@spk0611 with this fork the method cordova.plugins.notification.local.getTriggeredIds, does not work

katzer commented 7 years ago

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.

pa-de-solminihac commented 7 years ago

@katzer no way to keep backward compatibility ?

ammichael commented 7 years ago

@katzer any change incorporate actions on the release? I've been using actions on my app for almost and year now, and I've seen someone's Pull Request regarding this..

Would be a nice level up for the plugin!

JLNNN commented 7 years ago

@katzer Isn't it possible to check the OS version and then use different sources? Some older iOS devices don't support iOS10. And I guess it's a huge impact for some apps if you cut the compatibility.

kozuch commented 7 years ago

Why is the old notification API (the one until iOS 9) not working in iOS 10 when it is "only" deprecated? I thought that deprecated things should remain working until the code is finally removed from (which if I understand correctly is not the case of iOS 10?) ...

While I admire this plugin is open source and free of charge and we all want to have it support iOS 10 breaking backwards compatibility may be a big problem for a lot of people... but surely I personally would prefer have iOS 10 running even at the cost of breaking backwards compatibility while hoping iOS 10 market share will grow rapidly.

katzer commented 7 years ago

@JLNNN The 0.9.dev branch contains support for actions for both iOS and Android. But might not fully work anymore with iOS 10.

@ammichael, @pa-de-solminihac, @kozuch even the old API is still available its not fully working anymore. The new API provides some new features and has also lost some features. Keeping backward compatibility means I have to maintain 2 complete independent code bases in one plugin. Thats out of my resources.

Might be an option to release one version with contains sources for iOS 9 & iOS 10. But after I will remove the old code.

chmac commented 7 years ago

Working on iOS 9 + 10

I've just spent an hour or two testing, and with this version, I have notifications working on both iOS 9 and iOS 10. I only get notifications when the app is not running on iOS 10, I guess it's an iOS change.

Thanks @katzer for the awesome plugin and @notclive for a quick fix for iOS 10.

@katzer Any chance of merging that change? It's pretty small and seems to work on both iOS 9 and 10 for me at least...

katzer commented 7 years ago

@chmac I know this fork. It's a quick way fixing some things. The current ios10-branch does similar.

chmac commented 7 years ago

@katzer I also tried the ios10 branch, but for me that didn't work. I was not seeing notifications on iOS 10. At least, that's what I remember! It might have been that I didn't realise notifications only show up when I'm not in the app, I'm not 100% sure at this point.