来自 Azure 通知中心的推送通知 (Xamarin.iOS)

Push notifications from Azure Notification Hub (Xamarin.iOS)

我已经尝试了 Android 和 Windows 推送通知,一切正常。然而,在iOS这边,出了点问题。

我正在尝试使用这些教程向我的 Xamarin.iOS 应用添加推送通知

从 Azure 测试发送我得到 "Message was successfully sent, but there were no matching targets."

我按原样执行了所有步骤,但是当我设置断点时,我总是得到 "IsRegistered =false":

AppDelegate.cs

private SBNotificationHub Hub { get; set; }
    public const string ConnectionString = "Endpoint=sb://...";
    public const string NotificationHubPath = "NotificationHubName...";


     public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
            {
                // Set our preferred notification settings for the app
                var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
                    new NSSet());

                // Register for notifications
                UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
                bool IsRegistered = UIApplication.SharedApplication.IsRegisteredForRemoteNotifications;

                return true;
            }
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            Hub = new SBNotificationHub(ConnectionString, NotificationHubPath);
            Hub.UnregisterAllAsync(deviceToken, (error) =>
            {
                if (error != null)
                {
                    // Error unregistering
                    return;
                }
                // Register this device with the notification hub
                Hub.RegisterNativeAsync(deviceToken, null, (registerError) =>
                {
                    if (registerError != null)
                    {
                        // Error registering
                    }
                });
            });
        }

        public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
        {
            if (null != userInfo && userInfo.ContainsKey(new NSString("aps")))
            {
                // Get the aps dictionary from the alert payload
                NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary;
            }
        }

我的问题是;

  1. 为什么我没有注册?
  2. 我如何知道我为什么不注册?
  3. Xamarin 是否支持来自 Azure 通知中心的 iOS 11.0 推送通知?

注意:我正在使用

使用物理 iPhone 设备解决。

"The simulator does not do Push Notifications. And to push from a server, you have to have device(s) to push to as well as your app on that device."


"The iPhone Simulator is unable to receive push notifications or successfully register for them."