我喜歡展示在標籤中最新的推送通知我的主要故事板我使用此代碼顯示在我的AppDelegate.m警告消息:是否可以在StoryBoard中的標籤中顯示最新的推送通知?
-(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;
但它不起作用。
有人可以幫助我嗎?
謝謝:)
@j_Shapiro B其他方法不會爲我工作:(但我確切地說你是如何說的。 –
給我更多信息繼續...他們怎麼不工作?在創建通知之前alertString爲零嗎?你看到什麼錯誤? –
Push沒有錯誤,但標籤沒有填充Push消息。 –