Will iOS awake my app when i receive silent push notification?(When app is not in running state)

前端 未结 4 763
盖世英雄少女心
盖世英雄少女心 2020-12-09 22:38

Update Question :

The requirement is; as soon as I receive silent notification, I want to run a web service and show the one liner in the notification bar.

4条回答
  •  长情又很酷
    2020-12-09 22:55

    You CAN get a PUSH-notification and work with it. I know a little way to do this... Open the AppDelegate.m and and find or put this method - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions. After that, put into this method code like mine:

    NSDictionary *userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
    
    if (userInfo) {
        NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];
    
        NSString *alertType = [apsInfo objectForKey:@"type"]; //my own param in PUSH-notification
        globalPushType = alertType;  //global variable for working with it in some ViewControllers after app's load
    }
    

    I know, this helps a lot of people. =)

提交回复
热议问题