Murali
Murali

Reputation: 1889

Push Notification issue with FCM in iOS13

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

Answers (2)

AJ Negi
AJ Negi

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 {

        }
}
  • also check your APNS certificate on FCM, it must .p12 type must be available in keychain that you are using for your current XCode version

Upvotes: 1

Murali
Murali

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

Related Questions