gpt4 book ai didi

ios - 如何使用 branch.io 捕获参数?

转载 作者:可可西里 更新时间:2023-11-01 06:24:08 26 4
gpt4 key购买 nike

我开始使用https://branch.io/在 iOS 应用中。

我现在面临的问题是:如何捕捉传入链接及其参数?

按照文档 here .

我到了这一步,有这个链接:

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;
}

这是我在调试控制台中得到的:

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;
}

现在的问题是,使用什么代码(在应用程序内部)来获取数据 block :“315.0,419.0”?

最佳答案

Alex 和 Branch 在这里:这是一个很好的问题,我们应该在我们的文档中更清楚地说明这一问题!

当您生成一个链接(例如 http://myapp.app.link/A1bcDEFgHi )时,您可以设置您想要的任何数据参数,您将在 initSessionWithLaunchOptions() 调用中取回它们(如记录 here ).您的回调数据可能如下所示:

{
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),我们只会捕获该参数并将其传递给您:

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

关于ios - 如何使用 branch.io 捕获参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37719046/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com