我正在尝试为Xamarin iOS应用程序设置推送通知。我已确保使用具有必要权限的配置文件(在iOS开发者门户中启用推送通知)。我已验证我正在我的应用程序中使用所述供应配置文件。在我的AppDelegate中,在FinishedLaunching方法中,我正在执行以下代码:
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);
}
我可以成功看到提示,询问用户是否允许推送通知。问题是,当我点击
Allow
,以下两个重写方法均未命中:
RegisteredForRemoteNotifications
FailedToRegisterForRemoteNotifications
我还验证了,在我的iOS项目设置中
Enable BackgroundModes
检查以及
RemoteNotifications
选中的。
有人对此有任何问题吗?如果有,你是如何解决的?