0

我已经在 ASP.Net Core Web API 上使用 AppCenter 实现了推送通知。服务器向 AppCenter 发送 HTTP 请求,AppCenter 负责将通知推送到 Android 和 iOS 各个平台。

移动应用程序是使用 Xamarin Forms 开发的。我在这里关注了微软文档

Xamarin Android 应用程序像魅力一样接收每个推送通知。

问题出在 Xamarin iOS 应用程序上。设备没有收到任何推送通知。

这是我所做的 iOS 设置:

  • 在生产(非开发)权利中启用推送通知
  • 在我的 Apple 开发人员帐户中为推送通知创建了一个 APN 密钥以用于生产
  • 为 AppCenter 设置提供 iOS APN 密钥(带有 APP ID、前缀...)
  • 在 info.plist 中以后台模式启用远程通知
  • 通过将 AppCenterAppDelegateForwarderEnabled 键添加到 info.plist 来禁用 swizzling
  • 在 AppDelegate 中重写 DidReceiveRemoteNotification 并实现方法 RegisteredForRemoteNotifications , FailedToRegisterForRemoteNotifications

然后,我已经在生产模式下成功地将应用程序发布到了 TestFligth。

启动应用程序时,我通过调用方法获取 appcenter 设备 InstallId AppCenter.GetInstallIdAsync()

最后,当发送推送通知时,什么也没有发生。而且我没有任何日志来搜索问题。

我错过了什么让它工作吗?

4

1 回答 1

0

AppCenter 为每个平台提供不同的 AppSecret。你应该做 :

        if (Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.iOS)
        {
            //Start AppCenter Push notification with iOS app secret
            AppCenter.Start("xxxxxxxxxxxxxxxxxxxxxxx", typeof(Push));
        }
        else if (Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.UWP)
        {
            //Start AppCenter Push notification with UWP app secret
            AppCenter.Start("xxxxxxxxxxxxxxxxxxxxxxx", typeof(Push));
        }
        else if(Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.Android)
        {
            //Start AppCenter Push notification with Android app secret
            AppCenter.Start("xxxxxxxxxxxxxxxxxxxxxxx", typeof(Push));
        }
于 2019-05-20T18:27:57.643 回答