[英]Push Notification Service Extension in iOS is not getting executed
所以我根据这里提到的指南创建了一个 Xamarin 形式的 iOS 通知服务扩展 [ https://docs.microsoft.com/en-us/xamarin/ios/platform/user-notifications/enhanced-user-notifications?tabs =窗口][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 通知中心
确保您已使用精确的捆绑配置文件而不是通配符配置文件对应用程序进行签名,并记住模拟器不支持通知,所有这些都适用于“注册仍在进行”。
如有疑问,请检查您的通知是否在真实设备上的临时发布中工作,如果是,则上述原因是原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.