Reputation: 1889
I am using FCM for push notifications. I used to refresh the content of the app using the below method
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
Now with iOS13 this method is not firing anymore. I have included apns-push-type and apns-priority as well.
Upvotes: 1
Views: 3367
Reputation: 54
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if #available(iOS 13.0, *) {
// your code
completionHandler(UIBackgroundFetchResult.newData)
} else {
}
}
Upvotes: 1
Reputation: 1889
I found the issue.
UIApplication.shared.registerForRemoteNotifications()
this has to run for every launch. Better to keep this in didFinishLoadingWithOptions method. In my previous version, I used to call this for the first time but looks like it has to be for every launch.
and make sure set delegates for notification and messaging also.
UNUserNotificationCenter.current().delegate = self
Messaging.messaging().delegate = self
Upvotes: 7