手机操作系统中显示的Bluemix推送通知,单击时,将无法启动应用程序

时间:2016-01-11 15:37:39

标签: push-notification ibm-cloud ibm-mobile-services

我正在使用Bluemix推送通知开发应用程序。当应用程序处于前台或后台时,会调用带有完成处理程序的didReceiveRemoteNotification()并且一切正常。

但是当应用程序未启动时,其他设备会发送通知。从顶部向下滑动时,手机会在系统通知中显示推送通知,但点击通知将无法启动应用。它只是驳回了通知。 Android和IOS也是如此。

如何通过点击通知启动应用程序?

谢谢和最诚挚的问候,

2 个答案:

答案 0 :(得分:1)

对于Android,您必须确保在AndroidManifest.xml内的所有活动中,您希望在点击通知后启动应用时启动以下内容:

<!--Notification Intent -->
<intent-filter>  
   <action android:name="<Your_Android_Package_Name.IBMPushNotification"/>   
   <category  android:name="android.intent.category.DEFAULT"/>
</intent-filter>

请勿忘记使用您的包裹名称代替Your_Android_Package_Name

有关详细信息,请参阅helloPush示例。

答案 1 :(得分:1)

对于iOS,您需要确保您还成功将应用程序注册到APNs服务。完成此操作后,您将能够通过单击收到的推送通知来打开该应用程序。

目标-C:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0){
     [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:categories]];
     [[UIApplication sharedApplication] registerForRemoteNotifications];
     }
     else{
     [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
     }

     return YES;
}
斯威夫特:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let notificationTypes: UIUserNotificationType = UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound
let notificationSettings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: categories)

application.registerUserNotificationSettings(notificationSettings)
application.registerForRemoteNotifications()
}

您可以在此处查看有关推送注册的更多信息:

Enabling iOS applications to receive push notifications

我还建议查看我们的Bluemix Push Sample:

BMS iOS helloPush Sample