如何用branch.io捕获参数? [英] How to catch the parameters with branch.io?
问题描述
我开始在iOS应用中使用 https://branch.io/ 。
I started to use https://branch.io/ in an iOS app.
我现在面临的问题是:如何使用参数捕获传入链接?
The problem I am facing now is: how to catch the incoming link with its parameters?
按照文档此处。
我得到了这个链接:
http://myapp.app.link/A1bcDEFgHi?XP=315.0,419.0
我的代码是:
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
Branch *branch = [Branch getInstance];
[branch initSessionWithLaunchOptions:launchOptions
andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) {
if (!error && params) {
NSLog(@"Here is params: %@",params.description); // I need to replace this, with code to get XP!
}
}];
return YES;
}
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler
{
BOOL handledByBranch = [[Branch getInstance] continueUserActivity:userActivity];
return handledByBranch;
}
以下是调试台中的内容:
Here is what I get in the debugging console:
2016-06-10 11:59:44.407 TheApp[1786:591391] Here is params: {
"$identity_id" = 2712491317999770034;
"$one_time_use" = 0;
"+click_timestamp" = 1465529273;
"+clicked_branch_link" = 1;
"+is_first_session" = 0;
"+match_guaranteed" = 1;
XP = "315.0,419.0";
"~creation_source" = "iOS SDK";
"~id" = 211224109823923327;
}
现在的问题是,使用的代码是什么(在应用程序内部)掌握大块数据:315.0,419.0?
Now the question is, what is the code to use (inside the app) to get hold of the chunk of data: "315.0,419.0" ?
推荐答案
Alex with Branch here:这是一个很好的问题,我们应该在我们的文档中更清楚一点!
Alex with Branch here: this is a good question, and one that we should probably make more clear in our docs!
生成链接时(例如, http://myapp.app.link/A1bcDEFgHi ),你可以设置你想要的任何数据参数,你将把它们带回你的 initSessionWithLaunchOptions()
调用(记录为这里)。您的回调数据可能如下所示:
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',
}
}
如果你追加查询链接URL(例如, http://myapp.app.link/A1bcDEFgHi? XP = 315.0,419.0 )我们只是捕获该参数并将其传递给您:
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'
}
}
这篇关于如何用branch.io捕获参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!