When an iOS user enters the app by clicking the push message, the Appdelegate
-(BOOL) Application: (uiapplication*) Application didfinishlaunchingwithoptions: (nsdictionary*) launchOptions
We can pass
NSDictionary* remoteNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
Get the push userinfo.
But Didfinishlaunchingwithoptions will be more than Mainviewcontroller viewdidload first execution, at this time certainly cannot present a new view, You should let Mainviewcontroller start and check if you received the push, and then open the corresponding view
If Remotenotification is not empty, then the user enters by pushing the message, then a property can be declared
@property (nonatomic) BOOL islaunchedbynotification;
Used to identify whether the user entered the app by clicking the notification message.
At this time
-(void) Application: (uiapplication*) Application didreceiveremotenotification: (nsdictionary*) UserInfo
Must be called, iOS7 can be used
-(void) Application: (uiapplication*) Application didreceiveremotenotification: (nsdictionary*) UserInfo Fetchcompletionhandler: (void (^) (uibackgroundfetchresult)) Completionhandler
Since this method is called, Mainviewcontroller has already been initialized, so we can register a push message listener in Mainviewcontroller to show the corresponding view, as follows:
// Subscribe to the Presentation view message and open a branch view directly [[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (presentview:) Name:@ " Presentview"object: nil"; // a pop-up message box prompts the user for a subscription notification message. Primarily for users when using the app, pop-up prompts [[Nsnotificationcenter defaultcenter] addobserver:self selector: @selector (shownotification :) Name:@ "Notification"object: nil];
Therefore, in the Appdelegate didreceiveremotenotification can be judged by the islaunchedbynotification to inform different presentation methods.
The iOS user clicks the push message into the app and automatically jumps to the corresponding Viewcontroller