samad5353 February 2016

What is the solution for push notification delegate to fire when app is in not running state?

How can we make fire the push notification delegates if app is not running state without tapping the received notification. 1. Received notification 2.Not tapping on notifications 3.Launching the app by clicking app icon

In this state how can i check if push notification received or not?

Answers


Tapani February 2016

See the comment here:

UIApplicationLaunchOptionsRemoteNotificationKey not getting userinfo

Basically set "content-available": 1 in the payload and application:didReceiveRemoteNotification:fetchCompletionHandler will be called.


Hitendra Hckr February 2016

There is a way, using that you can process your every push notification. add key content-available with value 1 in to your aps dictionary.

so it will look like,

{
    "aps" : {
        "alert" : {
            "title" : "Game Request",
            "body" : "Bob wants to play poker",
        },
        "badge" : 5
        "content-available" : 1
    }
}

If iOS system detects pushNotification with "content-available" key having value 1, it will call application:didReceiveRemoteNotification:fetchCompletionHandler: of your appDelegate.

Apple - Discussion

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 remote notification arrives. However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.

You need to enable background modes. enter image description here

Post Status

Asked in February 2016
Viewed 3,254 times
Voted 12
Answered 2 times

Search




Leave an answer