即使我的应用程序正在运行,是否也可以在通知中心中显示远程iOS5通知,例如“即使我正在运行,我现在也不在乎远程通知,而是将其显示在通知栏中好像我没有在跑“?
最佳答案
而是向用户显示UIAlertView。
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSLog(@"userInfo :%@",userInfo);
NSString* msg = [userInfo valueForKey:@"aps"];
if (self._VCObj.isViewLoaded && self._VCObj.view.window) {
// viewController is visible don't show.
}
else { // viewController is not visible
[[[UIAlertView alloc]initWithTitle:@"Title" message:msg delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil] show];
}
}
}
Tutorial