scb*_*998 2 objective-c apple-push-notifications ios parse-platform
我在我的app委托文件中放置了以下代码.理论上,它应该从推送通知中提取消息并将其显示在UIAlertview- 但它显示标题和蜡烛按钮,而不是其他任何内容.谁能看到我错在哪里?
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
pushText = [userInfo objectForKey:@"alert"];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:NSLocalizedString(@"News", "")
message:pushText
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[alert show];
}
Run Code Online (Sandbox Code Playgroud)
推送有效载荷具有以下结构:
{
"aps" : {
"alert" : "Push notification text"
}
}
Run Code Online (Sandbox Code Playgroud)
所以你需要首先拔出"aps"字典,然后你可以检索"alert"键的值:
pushText = [[userInfo objectForKey:@"aps"] objectForKey:@"alert"];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1927 次 |
| 最近记录: |