Notification Service Extension Not working

Hi Team,

I was trying to add NSE to my Project to show Rich messaging.
  1. Creation of the NSE target to the project - Successful.

  2. Creation of additional provisioning profile in developer portal for NSE and mapped it in XCode - Successful

  3. The APS payload contains the content-type: 1 and attachment url to download the media content - Successful.

  4. When notification arrive the will present method gets called first - Successful.

  5. The auto execution of Notification Service 'didReceive(_ request: UNNotificationRequest,

         withContentHandler contentHandler: @escaping
           (UNNotificationContent) -> Void)' - failure.
6. Tried running the target instead of main app - failure
7. Tried attaching a debugger to get break point - failure
8. Debug and Console logs - failure
9. Additionally tried the below option from every developer suggestion but no luck.


o  https://stackoverflow.com/questions/50853503/images-in-ios-push-notification
o  https://stackoverflow.com/questions/51722109/unnotificationserviceextensions-didrecieve-not-called
o  https://stackoverflow.com/questions/39663903/ios10-unnotificationserviceextension-not-called
o  https://stackoverflow.com/questions/46463680/notificationserviceextension-not-called
o  https://stackoverflow.com/questions/45483018/unnotificationserviceextension-not-working-on-iphone-5-ios-10

Could you please assist on the same to get it working as the notification service methods cannot be called explicitly and it needs to be triggered by OS.

A quick, faster response and resolution is much appreciated.
  • The APS payload must contains "mutable-content": 1 to trigger the extension.

Add a Comment

Replies

Does your aps payload include
Code Block
"mutable-content": 1

which is required to trigger the service extension
Hi Gualtier Malde,

Thank for your reply, much appreciated.

Yes, the payload contains "mutable-content": 1 and an attachment URL.

The payload also needs to include an alert dictionary with title, subtitle, or body. So I think if you have mutable-content, but are missing those, the NSE still won't be triggered
Thanks charliecruzan.

The payload looks good when arrived, meeting the compliance.I have attached the same for your reference, please have a look.
Note - I have removed value of the attachment url key as it shows error when pasting here (but that is valid url which contains asset)
fyi - Gualtier Malde

 [AnyHashable("aps"):
{  MobileMessage =  
{    actions =    (          
  {        background =        {      
    border = 1;         
  borderColor = "#000000";       
    color = "#ED2B09";       
 };       
 cornerRadius = 5;        
event = notificationOpened;        
font =        {          
color = "#F8F9FA";          
size = 12;         
 style = normal;  
      };  
      label = Usage;        link = "usage";      
}   
 );   
 constrainWidths = 1;   
 content =    {     
 background =      {      
  border = 0;      
  borderColor = "#000000";       
 color = "#FFFFFF";      };     
 body = "Sample In-App Message";     
 bodyFont =      {       
 color = "#000000";        
size = 12;        
style = normal;    
  };     
 graphic = "";     
 graphicBorder =    
  {        
border = 0;        
borderColor = "#000000";     
 };  
    title = Vodafone;   
   titleFont =     
 {       
 color = "#000000";       
 size = 14;      
 style = bold;    
  };   
 };   
 creativeId = "9de6da5b-e7d2-4502-9687-210be313e281";    
dismissEvent = messageDismiss;  
  eventId = "de1a23aa-539f-4b54-ad4d-fe28cd644494";  
  taskId = "16f9d1a6-f2de-4725-89a0-fd672f743311";  
  template = "creative.mobileInAppMessage.large";  
};  
alert = 
 {  
  body = "Sample In-App Message";   
 title = Vodafone;  };  
category = SASCollector;  
"mutable-content" = 1;
  sound = default;
},
AnyHashable("data"):
{  "attachment-url" = "";
}
]
Add a Comment

My basic issue was that the thumbnail image was not shown in the Push Notification when it was received. I resolved it by applying the following steps: TARGETS (main) -> Build Phases -> Embed App Extensions -> Uncheck "Copy only when installing"

  • Thank you so much! This worked for me perfectly too!

Add a Comment

My basic issue was that the target iOS version of the newly created extension was higher than the iOS version on the test device. The target iOS version of the extension does not depend on the target iOS version of the app. Project -> Targets -> your_extension -> General (tab) -> Deployment Info

  • This solved my case, thanks!

  • this is a great suggestion, i have run into this version mismatch between extensions and main apps before. the failure is silent if your device has a lower OS level than the one set in the build settings. good for user. bad for developer.

Add a Comment

Hello, @PrithiviApple

try using the real device, that works for me.

My issue was my Project "iOS Deployment Target" value was different than my main application target and Notification Service Extension.

My main application target and Notification Service Extension had the same "Deployment Info" version but that didn't match the Project

  • this worked for me , target was set to latest version.

    thank you very much.

  • Thank you! Been trying to find the issue out for days, this was the fix.

Add a Comment

In my case the solution was to uncheck "Copy only when installing" in the Embed Foundation Extensions inside Build Phases

Silent notification do not work me on ioS 17 when a real device in any confifuration : application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) this is not being called even in foreground. The minute the aps is silent i dont get anything

  • yes I am also facing the same issue, everything works fine but when silient/background notification is send then didReceiveRemoteNotification fetchCompletionHandler completionHandler is not being called, earlier it was working fine. As soon as we send contents the function is being called. Is there anyways to get silent notification such that we can remove the previous notification according to it

  • Silent notification does not fire if the payload in push has title and body. if the payload has title and body, notification extension service will fire, if payload does not have, the silent push will fire if in push has key "mutable_content" : true.

Add a Comment

Silent notification does not fire if the payload in push has title and body. if the payload has title and body, notification extension service will fire, if payload does not have, the silent push will fire if in push has key "mutable_content" : true.