【问题标题】:Azure Mobile Engagment with Xamarin Forms IOS not receiving push notificationsAzure Mobile Engagement with Xamarin Forms IOS 未收到推送通知
【发布时间】:2017-05-23 21:00:02
【问题描述】:

我按照微软提供的教程找到here

我已经配置了 Android 版本,并且运行良好。

我的问题在于我无法接收推送通知。一步表明我需要向 Azure 发送一个屏幕以开始从 Azure 发送和接收数据并启用实时监控。

我正在尝试通过用作登录页面的情节提要发送,但因为我的 IOS 项目中没有任何其他页面,因为 UI 位于项目的 PCL 部分中,它似乎不是工作。

当应用程序启动时,它会请求通知权限,证书是正确的,因为我只使用通知中心对它们进行了测试,应用程序甚至可以毫无问题地完成注册过程,但它仍然不会收到任何通知。

以下是接收、注册和注册失败的代码:

public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
{
    EngagementAgent.ApplicationDidReceiveRemoteNotification(userInfo, completionHandler);
}

public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
    EngagementAgent.RegisterDeviceToken(deviceToken);
}

public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
{
    Console.WriteLine("Failed to register for remote notifications: Error '{0}'", error);
}

这是 AppDelegate 中的设置代码:

    EngagementConfiguration config = new EngagementConfiguration
    {
        ConnectionString = "",
        NotificationIcon = UIImage.FromBundle("icon")
    };
    EngagementAgent.Init(config);



    if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
    {
        var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
            (UIUserNotificationType.Badge |
                UIUserNotificationType.Sound |
                UIUserNotificationType.Alert),
             null);
                UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
    }
    else
    {
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(
            UIRemoteNotificationType.Badge |
            UIRemoteNotificationType.Sound |
            UIRemoteNotificationType.Alert);
    }

我没有收到任何异常或崩溃。我不知道问题出在哪里。

【问题讨论】:

    标签: azure xamarin xamarin.ios xamarin.forms azure-mobile-engagement


    【解决方案1】:

    您是否为您的应用启用了静音远程通知? 为此,您需要将以下行添加到您的 plist.info

    <key>UIBackgroundModes</key>
    <array>
      <string>remote-notification</string>
    </array>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-16
      • 1970-01-01
      • 2021-06-13
      • 1970-01-01
      • 2016-07-22
      • 2021-05-28
      • 2016-11-24
      相关资源
      最近更新 更多