0

how to handle push notification when app is in foreground and background. I'm getting the below payload data.

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {

    FIRMessaging.messaging().appDidReceiveMessage(userInfo)
    print(userInfo)

// [title: push, body: hi, collapse_key: do_not_collapse, icon: icon, from: 27]

}

how to handle this payload to get notification?

7
  • I am also similar kind of payload but not getting notification in foreground or background . How did u handle this kind of payload Commented Jun 8, 2017 at 11:48
  • you can use BRYXBanner to show notification when app is in running state. Commented Jun 9, 2017 at 5:31
  • when app is in background or foreground means Commented Jun 9, 2017 at 5:32
  • banner is shown when app is in foreground. the format of payload must be as per apple to show notification in background Commented Jun 9, 2017 at 5:40
  • Thank You. May I know the format of payload for apple and who should provide this kind of payload . Please let me know this thing . Commented Jun 9, 2017 at 5:43

1 Answer 1

0

You already received the notification. This is up to you what action you want to perform. You can parse the payload and process the data accordingly.

If you are asking to handle the notification in App's "not running" state. Then iOS handles itself handles the notification to process and show but the format should be as per defined by apple.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.