Advertisement
Guest User

initBranchAndHandleLinksWithOptions

a guest
May 31st, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void)initBranchAndHandleLinksWithOptions:(NSDictionary *)launchOptions
  2. {
  3.     Branch *branch = [Branch getInstance];
  4.     [branch setDebug];
  5.     [branch accountForFacebookSDKPreventingAppLaunch];
  6.     [branch initSessionWithLaunchOptions:launchOptions andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) {
  7.         NSLog(@"deep link data: %@", [params description]);
  8.        
  9.         NSURL *url = [NSURL URLWithString:params[@"$deeplink_path"]];
  10.         if ([params[@"~channel"] isEqualToString:@"donation"]) {
  11.             NSDictionary *params = [URLParser parse:url];
  12.             if ([params[@"commandName"] isEqualToString:@"donation"]) {
  13.                 Debug(@"External donnation command sent");
  14.                 ExternalDonationCommand *command = [[ExternalDonationCommand alloc] initWithComandParameters:params];
  15.                 [command execute];
  16.                 return;
  17.             }
  18.             return ;
  19.         }
  20.        
  21.         if (params[@"referral"]) {
  22.             if (![[SharedPersistentStore objectForKey:isNotFirstInstall] boolValue]) {
  23.                 ExternalReferralCommand *command = [[ExternalReferralCommand alloc] initWithComandParameters:params];
  24.                 [command execute];
  25.             }
  26.            
  27.             if ([params[@"~feature"] isEqualToString:@"share_profile"]) {
  28.                 if ([params[@"source"] isEqualToString:@"1"]) {
  29.                     ExternalCharityProfileCommand *command = [[ExternalCharityProfileCommand alloc] initWithComandParameters:params];
  30.                     [command execute];
  31.                 } else if ([params[@"source"] isEqualToString:@"2"]) {
  32.                     ExternalCauseProfileCommand *command = [[ExternalCauseProfileCommand alloc] initWithComandParameters:params];
  33.                     [command execute];
  34.                 } else {
  35.                     return;
  36.                 }
  37.             } else if ([params[@"~feature"] isEqualToString:@"share_post"]) {
  38.                 ExternalPostDetailsCommand *command = [[ExternalPostDetailsCommand alloc] initWithComandParameters:params];
  39.                 [command execute];
  40.             } else {
  41.                
  42.             }
  43.         }
  44.     }];
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement