简体   繁体   中英

[iOS]Handle of receive push notification after User kill application manually

If user killed application manually, after that application receive push notification, how can i increase the badge number on application icon

  1. I try to turn on "backgroud mode", selected "remote notification" in Xcode Capabilities
  2. add follow source code in AppDelegate
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
    application.applicationIconBadgeNumber = 1
}
  1. install application, after it launched, kill it manually.
  2. I use push notification tool to send push notification with

"contentAvailable : 1"

  1. Application received notification (Notice pop up), but application Icon Badge Number was not display, I don't know how to do that

Could you help me please, Thank you very much.

Normal APNS payload is as following:

{
   "aps":{
       "alert": "Hello, world!",
       "sound": "default"
       "badge": "2"
   }
}

And silent APNS push payload is as following:

aps {
    content-available: 1
    alert: {...}
}

When a silent push notification reaches device, user does not know anything about the notification. But your app gets the notification and app will be given some time to download new content and present it to the user.

If you kill App, user can't get any alert when a silent push notification reaches device! So check your payload for this!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM