Can't handle push notifications when app is ru

2019-06-10 07:55发布

问题:

In documentation for method

application:didReceiveRemoteNotification:fetchCompletionHandler:

said

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.

I set 'background fetch' and 'Remote notifications' option in .plist and 'launch due to background fetch event' option in scheme settings. If my app running foreground and received push, this method called and all seems ok. But when i run my app from xCode and then move it to background mode (by pressing home button), it won't react on breakpoints or NSLogs in method above when push sent. System displays push notification, but i still can't do some actions when push arrives.

Is it possible to handle push notifications when app is running background?