Reputation: 57
I was trying to make a new NotificationService Extension on my app, so I deleted the existing Notification Service Extension directly in Project Navigator, including NotificationService.swift and its folder, and tried to create a new target of NotificationService Extension.
After new extension created, the method, "didreceive" in new NotificationSerivce.swift has never been called anymore.
How could I have them work?
Upvotes: 1
Views: 5873
Reputation: 227
I know it's too late, but might be helpful for others as well who are looking for a solution.
Just check your deployment target for the extension. I had the same issue. Mine was 10.2 while the device had 10.0.2. After changing the deployment target to 10.0 the UNNotificationServiceExtension worked like a charm.
Upvotes: 17
Reputation: 1898
Did you do a good clean (CMD-SHIFT-K)after deleting?
Have you tried recreating in XCode via File > New > Target... and then choosing the Notification Service Extension (seems you did, but just checking) AND making sure you embedded it in BOTH your project and app and the end?
And did you check your extension’s Info.plist, and make the appropriate changes to the NSExtensionAttributes dictionary are there and make sure the value of the UNNotificationExtensionCategory key is the same as your category name?
Next is your project set up to show notifications as on-screen alerts to the user? The extension doesn't work on "silent" notifications (e.g. badges).
Upvotes: 2