I have an application that uses Remote / Push notifications.
The background mode is used for remote notification, and everything works as expected. The application wakes up and receives all the necessary data from the server.
But if the Push notification notification is not removed from the Notification Center and the user clicks it, the method application: didReceiveRemoteNotification: fetchCompletionHandler:will be called again, which means that it will send a new request to the server, and this is undesirable behavior.
The first option is to check the status of the application, but this causes me problems when the application is paused. I need to do something like the code below, but this does not work for me:
if([UIApplication sharedApplication].applicationState == UIApplicationStateActive || [UIApplication sharedApplication].applicationState == UIApplicationStateBackground){
}
if([UIApplication sharedApplication].applicationState == UIApplicationStateInactive){
}
: , .
, application:didReceiveRemoteNotification: fetchCompletionHandler:?