简体   繁体   English

深层链接iOS推送通知

[英]Deep Linking iOS Push Notifications

I'd like to be able to send the viewer to a specific view in the app when they get the push notification, based upon what I send them. 我希望能够根据我发送的内容,在收到推送通知时将查看器发送到应用中的特定视图。

    "aps": {
        "alert": "look at this stuff",
        "view": "wc1"
    }

the view 'wc1' is just a tag in a collection view. 视图'wc1'只是集合视图中的标记。 So what i'd really like to know is, if the user is deep in my app, and they receive a push notification, how do I send them back to the collection view screen. 所以我真正想知道的是,如果用户深入我的应用程序,并且他们收到推送通知,我该如何将它们发送回集合视图屏幕。

I've come across the term deep linking, but not been able to find anything on it thus far. 我遇到了深度链接这个术语,但到目前为止还没能找到任何东西。 Any direction would be really helpful. 任何方向都会非常有用。 Thanks! 谢谢!

When application is loaded you can detect that in your appdelegate class in that method: 加载应用程序后,您可以在该方法的appdelegate类中检测到:

 didFinishLaunchingWithOptions 

NSDictionary *pushNotification = [options objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

if(pushNotification )
{
    //Handle remote notification
}

If application is still running in background and notification came, you can detect that also in your AppDelegate class: 如果应用程序仍在后台运行并且发出通知,您也可以在AppDelegate类中检测到:

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

Try to move your dictionary entry for view outside of the "aps" dictionary. 尝试移动词典条目以便在“aps”词典之外查看。

{
    "aps": 
    {
        "alert": "look at this stuff"
    }
    "view": "wc1"
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM