3

有没有办法使用 bluemix 发送静默或混合远程通知?仪表板中没有这样的选项。

我希望我的应用在接收远程通知时在后台获取数据。

编辑(从评论中复制粘贴):

我的意思是从 Bluemix 端发送混合推送通知的方式是什么,而不是客户端如何处理它。解决方案是使用 REST API:

POST https://mobile.eu-gb.bluemix.net/imfpush/v1/apps/$(app_id)/messages 

与身体:

"settings": { "apns": { "type":'MIXED' }
4

1 回答 1

-1

通知的处理是在客户端完成的,您想要做的当然是可能的。从此处链接的推送通知的 Bluemix 文档中获取

静音通知不会出现在设备屏幕上。这些通知由应用程序在后台接收,它会唤醒应用程序长达 30 秒以执行指定的后台任务。用户可能不知道通知到达。要处理静默推送通知,请在 appDelegate.m 中实现以下方法。

// For Objective C

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler
{
    NSNumber *contentAvailable = userInfo[@"aps"][@"content-available"];
    if([contentAvailable intValue]== 1){
        [[IMFPushClient sharedInstance] application:application didReceiveRemoteNotification:userInfo];

        //Perform background task
        NSLog(@"Received a silent push..");
        NSLog(@"userInfo: %@", userInfo.description);
        _appDelegateVC.result.text = userInfo.description;
        handler(UIBackgroundFetchResultNewData);
    }
    else{
        //Normal Notification
        [[IMFPushAppManager get] notificationReceived:userInfo];

        NSLog(@"Received a normal notification.");
        NSLog(@"userInfo: %@", userInfo.description);
        _appDelegateVC.result.text = userInfo.description;
        handler(UIBackgroundFetchResultNoData);

    }
    //Success
}

服务器为静默通知发送的 contentAvailable 值等于 1。

于 2015-11-17T15:13:46.863 回答