【发布时间】:2014-11-23 21:55:11
【问题描述】:
我正在使用 Parse 向我的应用程序发送推送通知。我想要的是,当用户从锁定屏幕滑动通知或从主屏幕点击它时,它会打开应用程序并在 UIAlert 视图中显示推送通知的文本。
我想它会插入应用程序委托的 didfinishlaunchingwithoptions 方法,但我真的不知道如何提取警报文本。
任何建议将不胜感激。
所以下面是我显示警报的代码 - 它正在工作,但它显示完整的 JSON 消息 - 当我尝试使用 objectForKey:@"alert 语句来尝试仅提取“警报”部分时推送通知,警报的消息部分不显示任何内容。
- (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];
}
【问题讨论】:
标签: ios objective-c parse-platform apple-push-notifications