Open Specific View when Opening App from Notification

前端 未结 3 1115
梦如初夏
梦如初夏 2020-12-04 12:28

I have just added push notifications to my app. I\'m wanting to have so that when a user opens the app from a notification, it will open a specific view controller and not

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 13:12

    If the app is opened from a notification, either of the two methods from your app delegate will be called

    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    

    OR

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    

    In case of the latter, the launchOptions will let you know if the app was launched due to a remote notification or some other reason (see Launch Option Keys here)

    Put in a check in these methods so that the specific viewcontroller will be opened if the app is launched from a notification.

提交回复
热议问题