iOS 10 don't call Notification Service Extension

牧云@^-^@ 提交于 2019-12-04 23:32:59
Kamilton

Check your deployment target on Service Extension.

I had deployment target set to 10.2 when testing on device with 10.1 and extension wasn't called until I changed it.

Another issue might be debugging.. In order to make it work You need to attach Service Extension Process. In Xcode menu Debug > Attach To Process > Name of your extension

  1. Rather then running the app. You have to run service extension as the target. Then it will ask for which app you have run service extension, then select you app and it will send notification.

  2. Make sure the deployment target is less than the device OS in service extension.

  3. Please ensure payload should contain "mutable-content": 1.

    {"aps" : {
            "alert" : {
                "title" : "Introduction To Notification",
                "subtitle" : "Session 707",
                "body" : "New Notification Look Amazing"
            },
           "sound" : "default",
            "category" : "message",
            "badge" : 1,
            "mutable-content": 1
        },
        "attachment-url": "https://api.buienradar.nl/Image/1.0/RadarMapNL"
    }
    
  4. Dont add "Content-available" flag in aps, if need to add make it 0. "Content-available" : 0,

Your push notification payload should contain the "mutable-content" : 1 key value pair.

The remote notification’s aps dictionary includes the mutable-content key with the value set to 1.

Ex of push notification payload JSON:

{
  "aps":{
          "alert": {
                    "body": "My Push Notification", 
                    "title" : "Notification title"},
          "mutable-content" : 1,
          "badge":0},
}

This works perfectly fine and i get the Push notification as follows:

Also Note That :

You cannot modify silent notifications or those that only play a sound or badge the app’s icon.

You can try Pusher or Houston for testing the Push Notifications.

I was getting crazy. Finally I realized that I had the deployment target of Notification Service Extension was 10.3 (my phone too). I changed to 10.2 and it works perfectly

I have the same issue but my problem was notification extension is "app". It should be appex

you need to add "mutable-content": 1 to your payload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!