你好 !我正在尝试使用Azure Notification Hub在我的 xamarin iOS 应用程序上添加通知。按照本教程(https://docs.microsoft.com/en-us/azure/notification-hubs/xamarin-notification-hubs-ios-push-notification-apns-get-started)之后,我遇到了一个问题在我的 appdelegate.cs 文件中:RegisteredForRemoteNotifications方法从未被触发,因此我的应用程序无法在我的集线器上注册。通知的所有权限都已完成,设置也是如此,我做了很多研究,但没有一个解决方案适用于我的情况。我已经尝试过Xamarin.iOS RegisteredForRemoteNotifications not called在我的 FinishedLaunching 方法中,我有:if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)){ UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound, (granted, error) => { if (granted) { InvokeOnMainThread(UIApplication.SharedApplication.RegisterForRemoteNotifications); } });}else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)){ var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications();}else{ UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);}我的RegisteredForRemoteNotifications方法是:public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) { Hub = new SBNotificationHub(Constants.ListenConnectionString, Constants.NotificationHubPath); Hub.UnregisterAllAsync(deviceToken, (error) => { if (error != null) { Console.WriteLine("Error calling Unregister: {0}", error.ToString()); return; }
1 回答
- 1 回答
- 0 关注
- 183 浏览
添加回答
举报
0/150
提交
取消