didReceiveRemoteNotification is not running when app is running (FOREGROUND)

前端 未结 1 1016
慢半拍i
慢半拍i 2020-12-20 09:50

I have a strange case. My swift ios app is connected to Cloudkit. If the app is NOT running (background state), I receive my notifications badge and alert just fine, every t

相关标签:
1条回答
  • 2020-12-20 10:14

    You've implemented the wrong method. Implement:

    func application(_ application: UIApplication,
        didReceiveRemoteNotification userInfo: [NSObject : AnyObject],
        fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void)
    

    As the docs explain:

    Unlike the application:didReceiveRemoteNotification: method, ... the system calls this method when your app is running in the foreground or background.

    0 讨论(0)
提交回复
热议问题