gpt4 book ai didi

ios - 使用 bluemix for ios 的静默远程通知

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:47:32 25 4
gpt4 key购买 nike

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

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

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

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

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

与 body :

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

最佳答案

通知的处理是在客户端完成的,您想要做的当然是可能的。摘自 Bluemix 的推送通知文档链接 here

Silent notifications do not appear on the device screen. These notifications are received by the application in the background, which wakes up the application for up to 30 seconds to perform the specified background task. A user might not be aware of the notification arrival. To handle silent push notifications, implement the following method in 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
}

The contentAvailable value that is sent by the server for silent notifications is equal to 1.

关于ios - 使用 bluemix for ios 的静默远程通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33759606/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com