iOS11 swift silent push (background fetch, didReceiveRemoteNotification) is not working anymore
Final UPDATE 2017-10-31
Apple just had its official (Halloween) release of iOS 11.1
UPDATE 2017-10-09
Apple released iOS11.1 beta 2 today. Again they mentioned in their Release Notes the following note:
Notifications Resolved Issues
Silent push notifications are processed more frequently. (33278611)
I'm going to test again this beta 2 version and update this answer for your information.
UPDATE - Testing -> After some testing with different scenarios this bug seems to be fixed within the latest iOS11.1 beta 2 version. Now we can only wait for the official release. In some forums they assume that Apple will release iOS11.1 in late October.
Older post
I investigated a lot of time the last week to look for an answer regarding this issue. After reading the apple release notes (incl. the deprecated, changed and new functions) I tested the following situation:
I added the empty function to my AppDelegate
and now the silent push works again both in foreground and also in background:
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
logger.log.debug("Perform Fetch with completion handler TEST")
}
I'm not sure if this 'workaround' is related to the issue, that the following function application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
is not called in iOS11.
Nevertheless you can give it a try and give me feedback, if you identify the same behavior.
UPDATE 2017-09-25
The 'silent push' works now in my case in foreground and background mode, but not, if the app is suspended either from the user or from the OS. So this issue is still open and not fixed - any help appreciated!
For more information see also this thread:
Silent pushes not delivered to the app on iOS 11
UPDATE 2017-10-05
Apple released iOS11.1 beta some days ago. They mentioned in their Release Notes the following:
Notifications Resolved Issues
Silent push notifications are processed more frequently. (33278611)
Some developers are saying that the issue is fixed with this beta, other developers say that the issue is still present within some circumstances. Now it would be interesting when Apple is launching iOS11.1 for the customers.
iOS 13 and silent notifications
I was able to resolve this issue. Before I get into the solution, however, I want to mention that I ran into this problem only on iOS13 and with silent notifications. The same code was working with iOS12 with same feature.
Our app has a separate screen for requesting notification permissions when the app is launched first time. At this stage we register the device for notifications. Next time when the app is launched, we don't show this screen anymore. To get it to work on ios13, we had to re-register with APNS in AppDelegate's didFinishLaunchingWithOptions every single time. Again, on iOS12 silent notifications were working without re-registering with APNS but on iOS13 we have to re-register every single time.
I hope this helps anyone else running into this problem.
Related Topics
Why Are Doubles Printed Differently in Dictionaries
Accessing Appstate in Appdelegate with Swiftui's New iOS 14 Life Cycle
Multiple Type Constraints in Swift
Programmatically Navigate to New View in Swiftui
Downloading and Caching Images from Url Asynchronously
How to Generate Large, Ranged Random Numbers in Swift
Closure Use of Non-Escaping Parameter May Allow It to Escape
How to Specify That a Non-Generic Swift Type Should Comply to a Protocol
How to Add Material to Modelentity Programatically in Realitykit
Convert Swift Array to Dictionary With Indexes
What Are the Rules for Spaces in Swift
@Noescape Attribute in Swift 1.2
How to Check If Time Is Within a Specific Range in Swift
Swift Extension: Same Extension Function in Two Modules
Color Attribute Is Ignored in Nsattributedstring with Nslinkattributename