iOS中的推送通知服务扩展未得到执行

问题描述 投票:0回答:1

所以我已经按照此处提到的指南以Xamarin形式创建了iOS通知服务扩展[https://docs.microsoft.com/en-us/xamarin/ios/platform/user-notifications/enhanced-user-notifications?tabs=windows][1]

这是我的扩展代码,它与上述示例完全相同

 [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);
    }
}

但是我无法调试通知有效负载,也无法接收通知,正在注册,所以我假设我的配置正确,但是服务扩展无法运行

我是否缺少任何内容,任何输入都将有所帮助,仅供参考,我正在为此使用Azure Notification Hub

ios xamarin.forms xamarin.ios apple-push-notifications ios-extensions
1个回答
0
投票

请确保您使用精确的捆绑包配置文件而不是通配符配置文件对应用程序进行了签名,并且请记住模拟器不支持通知,所有这些都适用于“仍将进行注册”的情况。

如果有疑问,请检查您的通知是否在真实设备上的临时版本中正常工作,如果是,则是上述原因。

© www.soinside.com 2019 - 2024. All rights reserved.