我已经设置了一个注册远程通知的应用程序。
- (void)application:(UIApplication*)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSString *status = [NSString stringWithFormat:@"Notification Received:\n%@",userInfo.description];
NSLog(@"%@",status);
UIAlertView *alert=[[UIAlertView alloc]
initWithTitle:@"didReceiveRemoteNotification"
message:eventName
delegate:self
cancelButtonTitle:@"Hide"
otherButtonTitles:@"View",
nil];
alert.tag = kAlertTypeNotification;
[alert show];
[self vibrate];
if ( application.applicationState == UIApplicationStateActive ) {
// app was already in the foreground
**DO SOMETHING HERE**
}
else {
// app was just brought from background to foreground
}
}
所以,当应用程序未激活时,我会收到非常漂亮的横幅提醒,在 iPhone 上看起来很不错。
但是,当应用程序打开时,我似乎唯一的选择是呈现一个 UIAlertView。在我看来,这是侵入性的。有没有办法在 application.applicationState == UIApplicationStateActive 时显示横幅?或者,是否有实现这种功能的开源库?
感谢你的帮助!