2013-08-30 58 views
4

我想在應用程序處於活動狀態時忽略推送通知。我處理通知如下:禁用UrbanAirship警報

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

但是,當應用程序被激活和設備接收推送通知,將出現通知消息的UIAlertView中。我如何禁用UA的默認處理?

回答

6

我有同樣的問題,並找到解決方案。 如果定義委託方法displayNotificationAlert:UAPushNotificationDelegate協議與體,例如,則自動提醒將不會顯示:

{ 
    ... 
    [[UAPush shared] registerForRemoteNotifications]; 
    [UAPush shared].pushNotificationDelegate = self; 
    ... 
} 

- (void)displayNotificationAlert:(NSString *)alertMessage 
{ 
} 
1

如果不需要與推送通知本身做任何事情只是從你的代碼

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

刪除[[PushHelper shared] processPush: userInfo]應用程序運行時,didReceiveRemoteNotification方法只調用。

+0

真棒)),並且我怎樣才能處理通知時,應用程序從通知中心錄製消息後從後臺返回? – scholl

+0

您需要在didFinishLaunchingWithOption方法中處理它。通知負載將位於選項字典中 –