ios - iOS 中的推送通知服务扩展未执行

标签 ios xamarin.forms xamarin.ios apple-push-notifications unnotificationserviceextension

所以我根据这里提到的指南在 Xamarin 表单中创建了一个 iOS 通知服务扩展 [ https://learn.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 通知中心

最佳答案

确保您已使用精确的捆绑配置文件而不是通配符配置文件签署应用程序,并记住模拟器中不支持通知,所有这些在“注册仍将进行”时都适用。

如有疑问,请检查您的通知是否在真实设备上以临时发布方式运行,如果是,则原因是上述。

关于ios - iOS 中的推送通知服务扩展未执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59716433/

相关文章:

android - 找出 Xamarin 应用随机崩溃的原因

ios - 上传到 iTunesConnect 后构建消失

iPhone SDK : Is it allowed having two ad banners in a uiview?

c# - 如何使用 DependencyService 和接口(interface)委托(delegate)将 xamarin.android 特定功能的方法传递给 xamarin.forms?

ios - Xamarin Forms 工具栏/导航栏格式

ios - 如何使用 Xamarin 在 iOS 的 NavigationController 中更改 1 个字符的标题文本颜色

xamarin - 引用 ReactiveUI 7.4 时出现 iOS 启动错误

css - 仅iOS的CSS文件?

ios - SceneKit 中的多个串行动画

ios - 为什么 XCode 忽略我的部署目标?