0

So i have created a iOS Notification Service Extension in Xamarin forms according to the guide mentioned here [https://learn.microsoft.com/en-us/xamarin/ios/platform/user-notifications/enhanced-user-notifications?tabs=windows][1]

This is my extension code, its exactly the same as the example described above

 [Register("NotificationService")]
public class NotificationService : UNNotificationServiceExtension
{
    Action<UNNotificationContent> ContentHandler { get; set; }
    UNMutableNotificationContent BestAttemptContent { get; set; }

    protected NotificationService(IntPtr handle) : base(handle)
    {
        // Note: this .ctor should not contain any initialization logic.
    }

    public override void DidReceiveNotificationRequest(UNNotificationRequest request, Action<UNNotificationContent> contentHandler)
    {
        ContentHandler = contentHandler;
        BestAttemptContent = (UNMutableNotificationContent)request.Content.MutableCopy();

        // Modify the notification content here...
        BestAttemptContent.Title = $"{BestAttemptContent.Title}[modified]";

        ContentHandler(BestAttemptContent);
    }

    public override void TimeWillExpire()
    {
        // Called just before the extension will be terminated by the system.
        // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.

        ContentHandler(BestAttemptContent);
    }
}

But i'm not able to debug the notification payload nor am i able to receive a notification, the registration is taking place, so i'm assuming my configuration is correct, but the service extension fails to run

Am i missing something, any inputs would be helpful, fyi i'm using Azure Notification Hub for this

mfaani
  • 33,269
  • 19
  • 164
  • 293
Venky
  • 1,929
  • 3
  • 21
  • 36
  • I'm having a Similar issue with firebase cloud messaging, When you say registration is taking place your receiving a token of sorts? And i'd have to ask if you made sure your Permissions are setup , A-swell as that the Device your Debugging on has the Appropriate Certificates in the KeyChain – Azurry Jan 13 '20 at 14:30
  • Yep, everything is in place, i'm able to get a token and i can see the new profile for the extension app as well – Venky Jan 14 '20 at 11:19
  • I'm going to keep you Posted on this as If this is the case and you do get the token we're facing an Identical Problem if I find a solution i'll try and inform you in regards to the Azure side of it, But from what I can tell in my case at-least is that I'm missing a Certification somewhere or a setting as I receive the token but not the actual notification, Which just has me thinking that it might be Authorizing notifications on the device or something along those line's, U do get the Popup when the app starts for the first time? – Azurry Jan 14 '20 at 12:00
  • popup for what ?? – Venky Jan 15 '20 at 07:18
  • To allow Notifications on the Device u know the Promp When you download a app for the first time allowing access to notifications, Photos ect that kind of thing – Azurry Jan 15 '20 at 07:20
  • yep, i'm getting that pop up as well – Venky Jan 15 '20 at 11:38

1 Answers1

1

Insure you have signed the app with a precise bundle profile and not a wildcard profile, and remember that notifications are not supported in simulator, all this apply while "registration will still be taking place".

When in doubt check that your notifications are working in ad-hoc release on real device, if yes, then the above was the cause.

Nick Kovalsky
  • 5,378
  • 2
  • 23
  • 50
  • Normal notifications are working fine, everything is in place, and i'm testing this on a physical device as well, just need to know if anything special needs to be done apart from the above tutorial link that ive shared in my post – Venky Jan 14 '20 at 11:20
  • @Venky did you find a solution for this? I am also facing the same issue. – Prabakaran Jun 08 '22 at 09:06
  • @Prabakaran I have, it is working fine now – Venky Jun 10 '22 at 06:28