1

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?

samad5353
  • 381
  • 1
  • 5
  • 18

2 Answers2

1

See the comment here:

UIApplicationLaunchOptionsRemoteNotificationKey not getting userinfo

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

Community
  • 1
  • 1
Tapani
  • 3,191
  • 1
  • 25
  • 41
1

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

Community
  • 1
  • 1
Hitendra Solanki
  • 4,871
  • 2
  • 22
  • 29
  • I am already using content available : 1 But if app is not running state will this delegate fire? also if users doesn't tap the notification only did finish launching option is fired. – samad5353 Feb 08 '16 at 12:20
  • it will wake your app and execute method mentioned in answer, but iOS can't wakUp the app which is exited by forceQueit i.e. using slideUp to exit by pressing home button twice. – Hitendra Solanki Feb 08 '16 at 13:15