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?
Following the documentation here.
I got to this point, having this link:
http://myapp.app.link/A1bcDEFgHi?XP=315.0,419.0
and my code being:
- (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;
}
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: 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'
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With