2

我正在Xamarin中开发iOS应用程序,并且需要通过Amazon SNS从现有后台接收推送通知。Xamarin.iOS应用程序未运行时未处理亚马逊SNS推送通知

暂时我正在使用亚马逊网页发送测试通知到APNS_SANDBOX。

我写了我的代码,并创建了iOS应用程序的证书,当应用程序运行时,一切正常。但是,当应用程序处于后台或根本没有加载时,iOS设备不会收到通知。

在Xamarin Studio中的项目选项中,我在后台模式下启用了以下功能 已启用后台模式,后台提取,远程通知。 在iOS设备的常规设置中,后台应用程序刷新在全局和应用程序中均处于启用状态。

我想我一定错过了配置或苹果证书中非常基本的东西,但我无法弄清楚什么。

回答

1

从各种iOS/Objective C问题阅读各种解决方案后,我设法找到解决方案。正是这种特殊的question让我朝着正确的方向前进。 有我的代码有问题订阅推送通知iOS上运行时,8.0

我的原代码:

public static void Subscribe() 
    { 
     if (UIDevice.CurrentDevice.SystemVersion [0] >= '8') 
     { 
      UIApplication.SharedApplication.RegisterForRemoteNotifications() 
     } 
     else 
     { 
      UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; 
      UIApplication.SharedApplication.RegisterForRemoteNotificationTypes (notificationTypes); 
     } 
    } 

我的新代码:

public static void Subscribe() 
    { 
     if (UIDevice.CurrentDevice.SystemVersion [0] >= '8') 
     { 
      UIUserNotificationType types = UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert; 
      UIUserNotificationSettings settings = UIUserNotificationSettings.GetSettingsForTypes (types, null); 
      UIApplication.SharedApplication.RegisterUserNotificationSettings (settings); 
     } 
     else 
     { 
      UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; 
      UIApplication.SharedApplication.RegisterForRemoteNotificationTypes (notificationTypes); 
     } 
    } 

这种变化现在允许通知在应用程序处于后台或未运行时正确接收。

相关问题