gpt4 book ai didi

ios - 应用程序在后台时不显示推送通知

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

我正在尝试设置我的应用程序以接收来自 GCM 的推送通知。当应用程序在前台运行时,AppDelegate 中的方法正在调用:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
DLog(@"Notification received: %@", userInfo);
// This works only if the app started the GCM service
[[GCMService sharedInstance] appDidReceiveMessage:userInfo];

completionHandler(UIBackgroundFetchResultNoData);
}

示例日志是这样的:

Notification received: {
aps = {
alert = "myk myk";
badge = 2;
sound = default;
};
"gcm.message_id" = "0:1446730003823773%cc4efdeacc4efdea";
}

问题是当我的应用程序在后台时,通知中心根本没有任何信息,也没有显示警报/横幅。我检查了设置-> 通知,通知已为我的应用程序启用。当我进入我在后台的应用程序时,我会得到有关通知的信息,但这不是我想要的。

我使用的是 iOS 9.0.1 和 xCode 7.1为什么我的应用程序在后台时没有通知横幅?

最佳答案

将您的负载与 Apple 网站的示例进行比较

{
"aps" : {
"alert" : {
"title" : "Game Request",
"body" : "Bob wants to play poker",
"action-loc-key" : "PLAY"
},
"badge" : 5
},
"acme1" : "bar",
"acme2" : [ "bang", "whiz" ]
}

Alert json 可能是错误的。

关于ios - 应用程序在后台时不显示推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33546037/

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