-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed iOS 10 compat on the master branch #1107
Conversation
this worked for me. |
I am confused, does this work on the master branch or the iOS branch? I am getting the popup asking for permission, after that no notifications come up. I have tried using the ios 10 fix and this fix together and independently and nothing will work on ios 10. Any ideas? |
Master. Perhaps you're using it wrong? Plz share your code.. |
So currently my process is to create an event that starts right away to request permission
This makes ios and android ask for permission to access local notifications. After this I have a button that fires an event for 1 minute away from the current time.
Note this works perfectly on android, after 1 minute I get my local notification, I have also tried making the 'id' a math.rand followed by .toString to check if the issue was ID and the issue persists. |
@zocheyado The notification will only show in iOS10 if your application is running in the background. If the application is in the foreground, no notification will appear.
|
I just tested putting the application in the background and same issue. @jmcrthrs have you got it working on ios 10 ? If so did you use this fix or the ios 10 branch or neither. |
interesting to know that this is for master. I manually added it to the ios10 branch. @zocheyado - try changing id to an int. I also didn't use the "at" parameter. |
@shi11 How then did you set your time? every? Is there a "every minute" option for testing? I will try adding ios10 branch, this fix again, and changing the ID to an int |
@zocheyado it just fires when it's scheduled - defaults to now. |
@shi11 Correct me if I am wrong, but defaulting to "now" would no longer work because the notification will only fire in the background yes? I just tested on ios10 + this fix with id set to an int no luck using at, every or the default :/ |
@zocheyado hmm sorry, don't know what else might be causing it. I don't think "now" and whether it happens in the background are related. You've seen this thread: #1096 |
@EddyVerbruggen you're awesome! Thanks a bunch. So far so good! |
Works, thank you so much! +1 👍 🐑 |
Works! |
Hi, Thanks |
I still have not gotten this to work, anyone who could post how they install the repo + how they execute a local notification that actually works on ios 10 would be amazing. |
I signed up for github just to say I also have the same issue as @zocheyado. I've been waiting a few weeks now hoping that there would be a fix released for IOS 10. For Android everything schedules perfectly - uses the default noise, increments the number of alerts etc. For IOS9 it schedules an alert with no noise and does not increment the number of alerts as more come in. Possibly my coding error, but I haven't wanted to spend time on it because IOS10 doesn't work. For IOS10 it asks me if I'd like to allow notifications and even after allowing them (and making sure they are on in the settings) I still never receive any alerts when having the app in OR out of the foreground. It IS running in the background. FYI -- I manually added the code fix to the files changed. Any help would be greatly appreciated! Thank you. |
To clarify I am having the exact same experiance as @WindierTuna |
@zocheyado and @WindierTuna (welcome on GitHub!) I see a lot of 👍's here for the fix I provided so you may want to give this fork a try until my PR (or any other fix) is merged. |
Yes @EddyVerbruggen's fork is working for me. |
@EddyVerbruggen Do you happen to have an example of something incredibly basic so that we can remove the variable of our code? As in "Local notification in 1 minute". Etc so that we can test the fork without wondering if it is our code. Also I assume |
@zocheyado check the first example here, and that command is correct (remove any old one first of course: |
@EddyVerbruggen I actually have it working!!! Only thing left is badge number...any idea how to fix that? I assumed it would be tied to the alerts or do I have to set that manually somehow? Edit it is in the list of options
All bow to the honorable @EddyVerbruggen |
@zocheyado Could you tell me how it got worked for you, what changes you have made to your code to make it working. We also got allow notifications popup in IOS after that no notifications coming. |
@zocheyado We have removed old plugin and added new plugin using below command. |
So it just started coming through! I haven't touched it! I was sitting on the settings screen talking to a coworker and it just randomly came through after like 7 minutes of nothing. Now it's been coming every minute like I typed. This is awesome and not good at the same time, but oh well this is good progress. @zocheyado Any idea what options are required to be there? thanks so much for the help |
@zocheyado On the ios10.0.2 work? |
@zocheyado @EddyVerbruggen I removed old plugin added new plugin, now only on simulator notifications are coming. But no notifications are coming on iphone device. Any idea why notifications are not coming on device |
This worked for me. |
So I've traced my issue to actually be a couple of things. I needed this branch . I needed either an 'at' or an 'every' option. My application must be in the background in order for the notification to schedule (adding a time delay allowed me to hit the home button before it executed and see that it actually is working). My main problem now is that my app is apparently not polling the server when it is in the background and so no notifications are coming unless I go into the app and refresh then leave. However, the app not running in the background is a completely different problem than this is. Thank you everyone for the help with this plugin! |
@WindierTuna Yeah if you need your app to "do something" when a notification comes in and your app isn't running or launched because of the notification then you'll need to switch to push notifications which can be configured to give your app a limited amount of time to perform operations when a push message arrives. |
@EddyVerbruggen There is no notification coming in. This app actually reaches out to a server every 2 minutes to gather a new JSON object. If the new object has more in it than the last one then it schedules a notification to tell you there is new stuff. My issue is that on IOS (android is fine) when you push the home button it makes it so that my app has so network connectivity and then every 2 minutes it fails to reach out to the server. All I need to do is get my app to always be running in the foreground or background. However, I just assumed it would do this automatically like android does and I was wrong. Also, we are too far along in the process to change it so that the server sends notifications although I understand that is ideal. |
Eddy, Just to let you know we used your fork on our Jambuster app, no changes to our code whatsoever and it works very well. Form start to finish 10 mins. Thanks Rob |
Something fundamental has changed in IOS 10 with how local notifications work. We're unsure if its IOS10 or this plugin. I'll use examples. Our app monitors a users GPS position when driving and alerts them if they drive into London's Congestion Zone. When the user crosses into the congestion zone, we set up three reminders for later in the evening to alert them to pay. These reminders are created using local notifications. We always keep the app in the foreground for testing. IOS 8 IOS10 If we run the same code on IOS 10, we can see the same GPS trigger being set, we set the same local notification up but NO notification is received unless we put the app in the background in the gap between us creating the local notification and the trigger for the local notification firing. For testing purposes we have moved the local notification schedule to 30 secs after the GPS trigger. This is on the same code base with the same test. So is the issue with the way IOS 10 now handles local notifications OR is the issue with this plugin? It would be good to know. Also if this plugin has been abandoned then we need to look at what to do. Rob UPDATED Now we understand that the notification framework for IOS 10 has changed and that the standard behavior is for notifications to NOT be displayed unless the app is the background. So this matches what we have seen in our testing. This is a major change from Apple. We've also seen that @katzer has an IOS10 branch on the go, but that seems to be ONLY for IOS10, at time of writing 40% of iPhones are on IOS 9. The ability to create 'permanent' notifications in the drawer, not transient ones when the app is in the foreground is rather important to us. Enough that we will contribute to a fund to get this working for IOS 9 and IOS 10 as before :) It would be good to get a statement on what @katzer is planning so we can plan as well. Thanks Rob |
@WindierTuna @zocheyado @EddyVerbruggen In Controller we are calling function every 30 seconds, in that we are making ajax call to get response and we want to display response message as notifications. We are using below code to send notifications in controller, but notifications are coming in simulator but not coming on phone. formattedwmsString variable will have response message. If I put below code with static text in app.js in ionicready function then in phone after opening app and pressing home button, notifications starts coming on phone. Could you please helm me where I'm doing wrong? cordova.plugins.notification.local.schedule({ |
You can only display the notifications in the drawer when the app is in the background. You also don't have the
so we schedule the notifications for at least five seconds in the future. Here's our code lifted directly from our master source. We know this works as we've tested it to death.
This sets up four reminders for a user to pay the London Congestion Zone for 19:30. 20:30 and 21:00. We use an array to schedule them, as we had issues with scheduling them one at a time. I recall that the advice was to schedule even one notification in an array. However that could be wrong. The This code works as we spent all yesterday checking exactly this on Android and IOS on the Rob |
thanks @WindierTuna Its working now |
My app needs to schedule recurring notifications at custom intervals, such as every 15 minutes. Because iOS 9 and earlier did not support this, we ended up having to schedule each one manually and we were/are concerned about reaching the max limit of 64 that I understand is also a limitation of iOS. Its my understanding that iOS 10 now supports these kind of custom intervals where as previous versions of iOS did not. Is this correct? Does or will this plugin support the ability to create recurring notifications with custom intervals? If so, when will that be available? Also, has anyone else faced this issue and have any thoughts on the best way to work around it if and until it can work natively through iOS and this plugin... Thank you. |
I agree with @rwillett about to get a statement on what @katzer is planning. Seems to be clear that notifications will not come up when app is in foreground but what about the events? Trigger or Click events are not been fired at all with current API used. Is there any planning of changing to new API? any timeline? Thanks to all. |
Out of interest has anyone verified this fix on iOS 10.2? I updated yesterday to Xcode 8.2 and localnotifications not coming in. Setting notification as follows:
It's worth nothing I've only recently added the plugin, works perfectly on android. I manually changed the filed in Xcode to match this PR. |
@stoconnor. I believe we determined that the notifications don't display if your app is in the foreground, but if you delay the notification and then put your app in the background it will work. Just read through the comments above and try the various things. We had it pretty nailed down. |
@WindierTuna, I delay all my notifications and test them in background mode. Tried most of the above comments which lead me to believe there may be some change in iOS 10.2 that has stopped this functionality again. I'll try removing the plugin and adding the iOS branch to my app see if this make a difference but I had manually changed the files in Xcode and built it from Xcode. |
run that cordova plugin add https://github.com/Telerik-Verified-Plugins/LocalNotification |
@mauricioprzv Yes, that works with the app in the background, like the original one. |
Background local notification not working any updates? |
If you have a problem, raise it properly with a proper explanation of what you think should happen and what you have done. Your comment here had no information in it. |
@rwillett i have issue is something like when my app is running in foreground local notification works perfect but when my app go to background local notification is not working this description is fine or you need some more details? |
Raise a separate issue as you are hijacking anther thread. Fill in the template correctly with a proper explanation. I still don't understand what isn't working as we schedule notifications all the time, put the app into the background and they work. You have not said anything about versions, code, OS, hardware, errors, what you expect to happen. A single line saying "something doesn't work" is meaningless. The template is there for a reason, use it. |
One question: |
finally fixed :D |
Yeah :D |
In case merging the iOS10 branch takes a long time, or in case it's not compatible with cloud build tools like PhoneGap Build (which may not use the required Xcode version (8) of said branch), please consider this clean and easy fix for iOS 10 support.
Yes it still uses the old API that was deprecated since iOS 10, but it will be available in iOS for some time as Apple is always purposefully slow removing deprecated API's.
This fixes issues like #1096, #1034 and #1101 and I've also applied this patch to the Telerik fork in order to support the Telerik Platform (also a cloud build tool).