【发布时间】:2012-12-23 11:02:12
【问题描述】:
我喜欢在我的主 StoryBoard 的标签中显示最新的推送通知我使用此代码在我的 AppDelegate.m 中显示警报消息:
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSDictionary *test =(NSDictionary *)[userInfo objectForKey:@"aps"];
NSString *alertString =(NSString *) [test objectForKey:@"alert"];
NSLog(@"String recieved: %@",alertString);
UIApplicationState state = [[UIApplication sharedApplication] applicationState];
if (state == UIApplicationStateActive) {
UIAlertView *alertmessage=[[UIAlertView alloc]initWithTitle:@"Geier"
message:alertString delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertmessage show];
AudioServicesPlaySystemSound(1002);
}
}
我在我的 ViewController.m 文件 latestpush.text = @"%@",alertString; 中尝试过这个,但它不起作用。
有人可以帮我吗?
谢谢:)
【问题讨论】:
标签: iphone ios uilabel apple-push-notifications appdelegate