gpt4 book ai didi

iphone - 如何在应用程序的事件状态下将远程推送通知显示为横幅样式?

转载 作者:可可西里 更新时间:2023-11-01 03:58:24 24 4
gpt4 key购买 nike

我正在制作一个使用苹果推送通知的应用程序。当我的应用程序处于后台状态时,我可以通过横幅接收通知,但是当我的应用程序处于事件状态时,我可以通过此代码显示您已收到通知的警报:-

(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
}
}

但我想将通知显示为横幅。我会为此做什么?请提出建议。

最佳答案

你不能,如果你的应用程序处于事件状态(在前台运行),推送通知会直接发送到你的应用程序。通知中心不会处理通知。

您必须自己实现某种横幅。

关于iphone - 如何在应用程序的事件状态下将远程推送通知显示为横幅样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13601533/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com