[英]iOS how to change push notification title when app is running in foreground?
I'm using Urban airship in my app to receive push notifications and all works as expected. 我在我的应用程序中使用Urban飞艇来接收推送通知和所有预期的工作。 The problem is that when my app is running in foreground and a push received it shows Notification as title along with info in payload.But i want to show title as Notis instead Notification i tried this-
问题是,当我的应用程序在前台运行并收到推送时,它会将Notification显示为title以及有效负载中的信息。但是我想将title显示为Notis而不是Notification我尝试了此操作-
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
if ( application.applicationState == UIApplicationStateActive )
{
NSDictionary* aps = [userInfo valueForKey:@"aps"];
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Notis" message:[aps valueForKey:@"alert"] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
else
{
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
tabBarController.selectedIndex=2;
[self loadStatisticsInBackground];
[[UAPush shared] handleNotification:userInfo applicationState:application.applicationState];
}
[[UAPush shared] resetBadge];
}
But it shows two alerts one that i defined and another is system defined. 但是它显示了两个警报,一个是我定义的,另一个是系统定义的。 Any help would be appreciated.
任何帮助,将不胜感激。 Edit: Ok.. if it is not possible to change title of push notification then Is there any way that we can prevent push alert when app is running in foreground?I don't want to show when my app is running in foreground?
编辑:好吧..如果无法更改推送通知的标题,那么有什么方法可以阻止应用在前台运行时的推送警报?我不想在我的应用在前台运行时显示吗?
您仅可以检测您的应用程序是否正在前台运行,如果没有运行,则不会在-application: UAPush
:中将通知传递给UAPush
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.