问题
I have a bare-bones app to play with push notifications. I have the Notification Service Extension working. I can send a remote notification with an image URL and have it load.
I can't seem to get Notification Content Extension working. I've gone through multiple tutorials and they all say, just create a Notification Content Extension from the target menu and then inside the Notification Content Extensions Info.plist set the
UNNotificationCategory
to some string. Then when you push the notification, inside the "aps" json-block make sure to have category the same as UNNotificationCategory.
When I receive a notification, I try to swipe it down, left or right and nothing really happens. However, the service extension is working great.
I am using an iPhone 5 with ios10 and xCode 8.0. I read that at one point only devices with 3d touch could view the content extension but that since has since changed sine xCode 8 is out of beta.
Any ideas? How can I go about debugging this? I've tried running the app with the Notification Extension selected and printing out stuff inside
didReceive
but am not having any luck.
回答1:
Make sure to set the Extension's deployment target to the same as your Application target.
回答2:
Please check if you set the category identifier in your UNMutableNotificationContent()
For e.g.
let content = UNMutableNotificationContent()
content.categoryIdentifier = "awesomeNotification"
where "awesomeNotification" is the identifier for your UNNotificationCategory
回答3:
Such problem. iOS Content Extension work fine with iPhone 5s, SE, iPad2mini, but doesn't work with iPhoine 5, 5c:
UNUserNotificationCenter.current().supportsContentExtensions is false on iPhoine 5, 5c
回答4:
Despite what I read elsewhere on stackoverflow and online, expanding the push notification did not work on an iPhone 5 and IOS 10. I borrowed an iPhone 6+ and my code worked fine.
来源:https://stackoverflow.com/questions/40055754/ios-10-notification-content-extension-not-loading