Disable UrbanAirship alerts

I want to ignore push notifications when the application is active. I process notifications as follows:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { if (application.applicationState != UIApplicationStateActive) { [[PushHelper shared] processPush: userInfo]; } } 

But when the application is active and the device receives a push notification, a UIAlertView message appears with a notification. How to disable default processing from UA?

+4
source share
2 answers

I had the same problem and found a solution. If you define the delegate method displayNotificationAlert: of the UAPushNotificationDelegate protocol with an empty body, for example, then automatic warnings will not be displayed:

 { ... [[UAPush shared] registerForRemoteNotifications]; [UAPush shared].pushNotificationDelegate = self; ... } - (void)displayNotificationAlert:(NSString *)alertMessage { } 
+6
source

If you don’t need to do anything with the push notification itself, simply remove [[PushHelper shared] processPush: userInfo] from your code

 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { //nothing to do here } 

The didReceiveRemoteNotification method is called only when the application starts.

+1
source

Source: https://habr.com/ru/post/1499818/


All Articles