phone OS 中显示的 Bluemix 推送通知在单击时不会启动该应用程序

Bluemix push notification displayed in phone OS, when clicked, won't launch the app

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

但当应用未启动时,通知由另一台设备发送。当您从顶部向下滑动时,phone 确实会在系统通知中显示推送通知,但单击通知不会启动该应用程序。它只是驳回通知。这与 Android 和 IOS 相同。

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

谢谢并致以最诚挚的问候,

对于 Android,您必须确保在您的 AndroidManifest.xml 中包含以下内容,在您希望 Activity 单击通知后您的应用程序启动时开始:

<!--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 示例。

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

Objective-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;
}

Swift:

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 推送示例:

BMS iOS helloPush Sample