是否可以使用bluemix发送静默或混合的远程通知?仪表板中没有此类选项。

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

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

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

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

与身体:
"settings": { "apns": { "type":'MIXED' }

最佳答案

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

静默通知不会出现在设备屏幕上。这些通知由应用程序在后台接收,这将唤醒应用程序最多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。

10-07 19:31
查看更多