我喜欢在我的主 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;
但它不起作用。
有人能帮我吗?
谢谢:)