代码之家  ›  专栏  ›  技术社区  ›  jdmdevdotnet Ruslan Tushov

未命中远程通知方法

  •  0
  • jdmdevdotnet Ruslan Tushov  · 技术社区  · 9 年前

    我正在尝试为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 选中的。

    有人对此有任何问题吗?如果有,你是如何解决的?

    1 回复  |  直到 9 年前
        1
  •  0
  •   jdmdevdotnet Ruslan Tushov    9 年前

    哇!我觉得自己很愚蠢。

    结果证明 Xamarin.Forms Release 但是,如果解决方案配置设置为,则无法通过断点调试平台特定代码 释放 .将其设置为 Debug 修复它。我从来没有考虑过这一点,因为您可以在发布时调试断点 Xamarin.表单 .

    推荐文章