【问题标题】:Push Notification Service Extension in iOS is not getting executediOS 中的推送通知服务扩展未执行
【发布时间】:2020-04-30 03:43:36
【问题描述】:

所以我根据此处提到的指南在 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 通知中心

【问题讨论】:

  • 我在使用 firebase 云消息传递时遇到了类似的问题,当您说正在注册时,您会收到某种令牌吗?而且我不得不问您是否确保设置了您的权限,并且您的调试设备在 KeyChain 中具有适当的证书
  • 是的,一切就绪,我可以得到一个令牌,我也可以看到扩展应用程序的新配置文件
  • 我会让你在这个问题上发布如果是这种情况并且你确实得到了我们面临相同问题的令牌如果我找到解决方案我会尝试通知你关于它的 Azure 方面,但至少从我的情况来看,我在收到令牌而不是实际通知时错过了某处的认证或设置,这只是让我认为它可能是在设备上授权通知或类似的东西,当应用程序第一次启动时你会得到弹出窗口吗?
  • 弹出窗口是为了什么??
  • 要在设备上允许通知您知道提示当您第一次下载应用程序时允许访问通知、照片等类似的东西

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


【解决方案1】:

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

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

【讨论】:

  • 正常通知工作正常,一切就绪,我也在物理设备上进行测试,只需要知道除了上述教程链接之外是否需要做任何特殊的事情我在我的帖子中分享了
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-02-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多