sajith kannan
sajith kannan

Reputation: 145

Notification Service Extension is not working

I am creating an iOS app(Objective C and xcode 8.3). I have integrated push notifification with firebase. It is working fine. Now I need to show notification with an image(Rich Notification). I have created Notification Service Extension.I have created category identifier in app delegate and set it into the info.plist of Notification Service Extension. I have also enabled push notification for Notification Service Extension. I have added "mutable_content" in notification payload. The problem is that, when sending the notification controll is not triggering into the Notification Service Extension section.What will be the problem? did i miss anything?I wrote the following code block in DidFinishLaunchingWithOption.

  UNNotificationCategory* generalCategory = [UNNotificationCategory
                                               categoryWithIdentifier:@"GENERAL"
                                               actions:@[]
                                               intentIdentifiers:@[]
                                               options:UNNotificationCategoryOptionCustomDismissAction];

    // Register the notification categories.
   UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
[center setNotificationCategories:[NSSet setWithObjects:generalCategory, nil]];

Upvotes: 1

Views: 2066

Answers (2)

Wattholm
Wattholm

Reputation: 859

If you have done as Rohit suggests, what finally worked for me was the answer by choofie in this post:

iOS 10 Notification Content Extension not loading

TLDR: Make sure the extension's deployment target is set correctly.

Basically, when you add the extension as a target in your project, its default iOS Deployment Target under Build Settings may not be the same as that of your original app target. In my case the extension was set to target iOS 13.1 while my app's deployment target was at 12.0. Since my physical test device was still at iOS 12.X.X, I assume this is why the Notification Service Extension was not loading/working properly. Changing it to iOS 12.0 resolved my issues.

Upvotes: 0

Rohit Monga
Rohit Monga

Reputation: 21

Include "mutable-content": 1 in your payload and send notification again.

Upvotes: 2

Related Questions