I have many users complaining that when they migrated from iOS 10.3.3 to iOS 11 launched yesterday, they stopped receiving silent push notifications.
One thing is to be noted that, I have a setting in NSUSerDefaults if I have already asked the user for registering for push notifications. And I do :
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
Only if the user hasn't been asked before.
Now if user had already registered for notifications when he was on iOS 10.3.3, and upgrades to iOS 11, the code registerUserNotificationSettings:settings will never be called for him, until he reinstalls. Could that be an issue? However, I believe it is unnecessary for him to register again as he already is.
So how do I fix this?
From documentation:
It is recommended that you call this method before you schedule any
local notifications or register with the push notification service.
So it is advised to call it at least once per app launch, but before your server sends the push notification.
I'm having a similar issue to Push Notification not working in ios 8.3
The push notifications are being received by 8.1 iphones but those sent to 8.3 iphones are NOT received.
I have updated my xCode to the latest (6.3.1). That does not seem to be the issue here.
I'm trying to send the push notifications both through the app as well as parse.com. The app does request permission to receive push, but that is not the issue.
This was suggested as a possible solution, though I don't understand where to include it. I have it included already for stripe. Though the notifications related to sending users a message that a stripe payment was made isn't working either:
Did you put this in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions ???
Any other suggestions much appreciated.
You should receive incoming push notifications in the -application:didReceiveRemoteNotification:fetchCompletionHandler: method on your application delegate, this is consistently called for applications on cold start and when already running in iOS 7+.
After updating the OS from 8.1 to 8.3, the device token for the app may change. Thats why Apple always suggests to call the
[[UIApplication sharedApplication] registerForRemoteNotifications];
every time you open the app. And update the latest device token to your server database.
I am creating a simple timer app which will have a lot of focus on the today extension widget features. Users can start the timer from here by tapping.
The only problem is that I need to set a local notification from the widget. I have tried to use [[UIApplicaton sharedApplication] scheduleLocalNotification] but Xcode throws an error saying that shared application is unavailable in app extension. Is there any solution for setting a local notification from Today extension? Thanks in advance. Any help whatsoever is appreciated.
I am trying to send my updated location to a server whenever I receive a push notification.
I am able to receive a push notification when I killed my app from switcher but my
application:didReceiveRemoteNotification:fetchCompletionHandler
delegate method is not called.
I have spent five days resolving this issue without success. Please, if anybody has any idea about this that would be appreciated.
Thanks in advance!!
Since ios7 apps which are killed from switcher do not receive push notifications.
Documentation isn't clear about this, but apple support confirmed this.
You can see the answer from apple support here:
https://devforums.apple.com/message/925788#925788
another reference:
https://devforums.apple.com/message/873265#873265
I am triggering a background fetch by using the content-available flag on a push notification. I have the fetch and remote-notification UIBackgroundModes enabled.
Here is the implementation I am using in my AppDelegate.m:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
NSLog(#"Remote Notification Recieved");
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertBody = #"Looks like i got a notification - fetch thingy";
[application presentLocalNotificationNow:notification];
completionHandler(UIBackgroundFetchResultNewData);
}
When the app is running in the background, it works fine. (The notification is received and the app triggered the "looks like i got a notification" local notification, as the code above should do).
However, when the app is not running and a push notification is received with the content-available flag, the app is not launched and the didRecieveRemoteNotification delegate method is never called.
The WWDC Video Whats New With Multitasking (#204 from WWDC 2013) shows this:
It says that the application is "launched into background" when a push notification is received with the content-available flag.
Why is my app not launching into the background?
So the real question is:
Will iOS perform background tasks after the user has force-quit the app?
UPDATE2:
You can achieve this using the new PushKit framework, introduced in iOS 8. Though PushKit is used for VoIP. So your usage should be for VoIP related otherwise there is risk of app rejection. (See this answer).
UDPDATE1:
The documentation has been clarified for iOS8. The documentation can be read here. Here is a relevant excerpt:
Use this method to process incoming remote notifications for your app.
Unlike the application:didReceiveRemoteNotification: method, which is
called only when your app is running in the foreground, the system
calls this method when your app is running in the foreground or
background. In addition, if you enabled the remote notifications
background mode, the system launches your app (or wakes it from the
suspended state) and puts it in the background state when a push
notification arrives. However, the system does not automatically
launch your app if the user has force-quit it. In that situation, the
user must relaunch your app or restart the device before the system
attempts to launch your app automatically again.
Although this was not made clear by the WWDC video, a quick search on the developer forums turned this up:
https://devforums.apple.com/message/873265#873265 (login required)
Also keep in mind that if you kill your app from the app switcher
(i.e. swiping up to kill the app) then the OS will never relaunch the
app regardless of push notification or background fetch. In this case
the user has to manually relaunch the app once and then from that
point forward the background activities will be invoked. -pmarcos
That post was by an Apple employee so I think i can trust that this information is correct.
So it looks like when the app is killed from the app switcher (by swiping up), the app will never be launched, even for scheduled background fetches.
You can change your target's launch settings in "Manage Scheme" to Wait for <app>.app to be launched manually, which allows you debug by setting a breakpoint in application: didReceiveRemoteNotification: fetchCompletionHandler: and sending the push notification to trigger the background launch.
I'm not sure it'll solve the issue, but it may assist you with debugging for now.
The answer is YES, but shouldn't use 'Background Fetch' or 'Remote notification'. PushKit is the answer you desire.
In summary, PushKit, the new framework in ios 8, is the new push notification mechanism which can silently launch your app into the background with no visual alert prompt even your app was killed by swiping out from app switcher, amazingly you even cannot see it from app switcher.
PushKit reference from Apple:
The PushKit framework provides the classes for your iOS apps to
receive pushes from remote servers. Pushes can be of one of two types:
standard and VoIP. Standard pushes can deliver notifications just as
in previous versions of iOS. VoIP pushes provide additional
functionality on top of the standard push that is needed to VoIP apps
to perform on-demand processing of the push before displaying a
notification to the user.
To deploy this new feature, please refer to this tutorial: https://zeropush.com/guide/guide-to-pushkit-and-voip - I've tested it on my device and it works as expected.
Actually if you need to test background fetch you need to enable one option in scheme:
Another way how you can test it:
Here is full information about this new feature:
http://www.objc.io/issue-5/multitasking.html
I've been trying different variants of this for days, and I thought for a day I had it re-launching the app in the background, even when the user swiped to kill, but no I can't replicate that behavior.
It's unfortunate that the behavior is quite different than before. On iOS 6, if you killed the app from the jiggling icons, it would still get re-awoken on SLC triggers. Now, if you kill by swiping, that doesn't happen.
It's a different behavior, and the user, who would continue to get useful information from our app if they had killed it on iOS 6, now will not.
We need to nudge our users to re-open the app now if they have swiped to kill it and are still expecting some of the notification behavior that we used to give them. I'm worried this won't be obvious to users when they swipe an app away. They may, after all, be basically cleaning up or wanting to rearrange the apps that are shown minimized.
This might help you
In most cases, the system does not relaunch apps after they are force
quit by the user. One exception is location apps, which in iOS 8 and
later are relaunched after being force quit by the user. In other
cases, though, the user must launch the app explicitly or reboot the
device before the app can be launched automatically into the
background by the system. When password protection is enabled on the
device, the system does not launch an app in the background before the
user first unlocks the device.
Source:
https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
For iOS13
For background pushes in iOS13, you must set below parameters:
apns-priority = 5
apns-push-type = background
//Required for WatchOS
//Highly recommended for Other platforms
The video link: https://developer.apple.com/videos/play/wwdc2019/707/