MahmutTariq
MahmutTariq

Reputation: 237

APN receive notification data in a delegate when app is terminated

Is it possible to receive notification data when app is terminated without notification being pressed?

I'm using

func application( _ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {}

It works fine if the app is in foreground or background, but it has no effect if the app is terminated, so my question is it possible to handle notification data in a delegate if app is terminated and how?

Thanks.

Upvotes: 1

Views: 675

Answers (1)

Sneha
Sneha

Reputation: 1444

There are only following way to get Notification Data :

  1. If your app is open and you receive notification.(It will come in didReceiveRemoteNotification)
  2. If your app is in background and you tap on the notification to open the app.
  3. If your app is close and you receive a notification on device and you tap on notification you can open the app.(It will come in didFinishLaunchingWithOptions)

App will not be able to handled it if you don't tap on the notification. You can only process the old notification data by having a web service to give you the unread or unprocessed notifications.

Upvotes: 3

Related Questions