简体   繁体   English

iOS在前台运行时如何更改推送通知标题?

[英]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.

相关问题 应用在前台运行时收到 iOS 推送通知 - iOS push notification received when app is running in foreground 当应用程序在 iOS 前台时如何处理 Flutter FCM 推送通知? - How to handle Flutter FCM push notification when app in foreground for iOS? iOS如何在应用程序处于前台时处理解析JSON推送通知 - iOS How to Handle Parse JSON Push Notification when App is in Foreground 应用程序处于前台时未收到推送通知 ios flutter - Push Notification not received when app is in foreground ios flutter 在Swift,iOS 8,9中的App Foreground时推送本地通知 - Push Local Notification when App Foreground in Swift, iOS 8,9 当应用程序在前台时,IOS Play Sound接收推送通知 - IOS Play Sound on receiving push notification when app in foreground 当应用程序在前台时,iOS Swift 接收推送通知 - iOS Swift Receive Push Notification When App in Foreground App在前景上并收到推送通知消息(IOS)时发生钛合金崩溃 - Titanium Crash when App is on Foreground and receives a Push Notification message (IOS) 当应用程序处于前台时,Appcelerator iOS 推送通知不起作用 - Appcelerator iOS Push notification not working when app is in Foreground Flutter iOS 应用程序在前台时的 FCM 推送通知 - Flutter FCM push notification for iOS when app is in foreground
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM