How to detect iOS remote access username?

When the user selects the remote notification, the following callback is launched in the application delegate:

-application:didReceiveRemoteNotification:fetchCompletionHandler:

in this case, the application starts, and the state of the application is UIApplicationStateActive , which I interpret as a user that is executed when the notification is deleted.

problem: This method can also be called when a remote notification arrives, and the application is in the foreground with an inactive state .

Example : when you open the notification center window (swipe down the top edge of the screen) or UIAlert is open. In both cases, the state of the application is UIApplicationStateActive , and there is no way to find out if a user notification was received or a system click was received.

Q : how can I determine if the didReceiveRemoteNotification response to a user call with a remote notification and the arrival of a remote notification?

+5
source share
1 answer
 UIApplicationState state = [application applicationState]; if (state == UIApplicationStateActive) { //When your app is in foreground and it received a push notification } else if (state == UIApplicationStateInactive) { //When your app was in background and it received a push notification } 

In addition, didFinishLaunchingWithOptions will be called if the application was not running and the user listened to the notification. I have not tried, but I can assume that you can get information from the parameters.

+1
source

Source: https://habr.com/ru/post/1232845/


All Articles