我正在在我使用苹果推送通知的应用程序。 当我的应用程序在后台状态,那么我能够收到通知的一面旗帜,但是当我的应用程序处于活动状态,那么我能证明你曾经使用过此代码收到通知警报: -
(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive) {
NSString *cancelTitle = @"Close";
NSString *showTitle = @"Show";
NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Some title"
message:message
delegate:self
cancelButtonTitle:cancelTitle
otherButtonTitles:showTitle, nil];
[alertView show];
} else {
//Do stuff that you would do if the application was not active
}
}
但我想说明的通知的一面旗帜。 我会为它做什么? 请建议。