iOS push notification received when app is running in foreground

后端 未结 3 1671
旧时难觅i
旧时难觅i 2021-01-19 04:54

From my understanding, when app is running or in the foreground and a push notification is received, the app should NOT show any alert but the app delegate will call the

3条回答
  •  一向
    一向 (楼主)
    2021-01-19 05:40

    When the App is in foreground, it should not display anything.

    If you see alertView, it means you provided code for it.

    Something along the following lines:

    -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    {
        UIApplicationState state = [application applicationState];
    
        if (state == UIApplicationStateActive) {
            //app is in foreground
            //the push is in your control
        } else {
            //app is in background:
            //iOS is responsible for displaying push alerts, banner etc..
        }
    }
    

    If you have implemented pushNotificationDelegate

    [UAPush shared].pushNotificationDelegate = self;
    

    then override, and leave it blank

    - (void)displayNotificationAlert:(NSString *)alertMessage
    {
      //do nothing
    }
    

提交回复
热议问题