How to catch the parameters with branch.io?

允我心安 提交于 2019-12-03 17:22:34

Alex with Branch here: this is a good question, and one that we should probably make more clear in our docs!

When you generate a link (e.g., http://myapp.app.link/A1bcDEFgHi), you can set whatever data parameters you want and you'll get them back in your initSessionWithLaunchOptions() call (as documented here). Your callback data might look something like this:

{
    tags: [ 'tag1', 'tag2' ],
    channel: 'facebook',
    feature: 'dashboard',
    stage: 'new user',
    data: {
        mydata: 'something',
        foo: 'bar',
    }
}

If you append a query to the link URL (e.g., http://myapp.app.link/A1bcDEFgHi?XP=315.0,419.0) we just capture that parameter and pass it through to you:

{
    tags: [ 'tag1', 'tag2' ],
    channel: 'facebook',
    feature: 'dashboard',
    stage: 'new user',
    data: {
        mydata: 'something',
        foo: 'bar',
        XP: '315.0,419.0'
    }
}
Hodson

See this question: Best way to parse URL string to get values for keys?

There are also third party frameworks you can use to handle this. If you're using Cocoapods, go here and search for "Query".


UPDATE

I think you need to set up either URL Schemes or Universal Links in your app.

I have answered a previous question about URL Schemes here and you can checkout branch.io's documentation on Universal Links here


UPDATE 2

In your example output you would access XP as such params[@"XP"] but based on the other answer from Alex you would access it with params[@"data"][@"XP"]

Params is just a dictionary so you access it like you would any other dictionary in iOS.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!