Sau*_*abh 6 iphone xcode objective-c push-notification ios
我正在制作一个应用程序,我正在使用苹果推送通知.当我的应用程序处于后台状态时,我可以收到通知作为横幅,但当我的应用程序处于活动状态时,我能够显示通过此代码收到通知的警报: -
(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
}
}
Run Code Online (Sandbox Code Playgroud)
但我想把通知显示为横幅.我会为此做些什么?请建议.
| 归档时间: |
|
| 查看次数: |
2031 次 |
| 最近记录: |