daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Sep 21st, 2016 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. + (void)shareTicket:(TicketItem*)ticket fromViewController:(UIViewController<ShareActionHandler>*)vc {
  2.    
  3.     BranchUniversalObject *branchUniversalObject = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/ticket_details"];
  4.    
  5.     NSString *username = [UserAPI shared].userFirstName ? : [[UserAPI shared] getUsername];
  6.     branchUniversalObject.title = [NSString stringWithFormat:AMLocalizedString(@"link_share_title_ios", @"%@ is sharing a ticket with you."), username];
  7.     branchUniversalObject.contentDescription = [NSString stringWithFormat:AMLocalizedString(@"link_share_description_ios", @"%d bets to win %@!"), [ticket.totalBets intValue], [ticket.sportTicket.winningGross formatedStringWithCurrency]];
  8.    
  9.     branchUniversalObject.contentIndexMode = ContentIndexModePublic;
  10.    
  11.     NSString *imgUrl = [[ConfigManager shared] isApp:kConfigAppCasaPariurilor] ? @"http://score-alarm.com/a/HSG/casa_share_promo.jpg" : @"http://score-alarm.com/a/HSG/psk_share_promo.jpg";
  12.     branchUniversalObject.imageUrl = imgUrl;
  13.    
  14.     NSString *encryptedPin = [AESCrypt encrypt:ticket.pin password:SHARE_TIKCET_PASS];
  15.     [branchUniversalObject addMetadataKey:@"data" value:encryptedPin];
  16.    
  17.     BranchLinkProperties *linkProperties = [[BranchLinkProperties alloc] init];
  18.     linkProperties.feature = @"sharing";
  19.    
  20.     [branchUniversalObject getShortUrlWithLinkProperties:linkProperties andCallback:^(NSString *url, NSError *error) {
  21.         if (!error && url) {
  22.             NSLog(@"got short link!");
  23.             [branchUniversalObject showShareSheetWithShareText:[NSString stringWithFormat:@"short link: %@", url] completion:^(NSString *activityType, BOOL completed) {
  24.                
  25.                 if (completed) {
  26.                     NSLog(@"shared! activity type: %@", activityType);
  27.                    
  28.                     // TODO: report to flurry!
  29.                    
  30.                     [vc shareActionFinishedWithStatus:ShareActionCompleted];
  31.                 } else {
  32.                     [vc shareActionFinishedWithStatus:ShareActionCancelled];
  33.                 }
  34.             }];
  35.         } else {
  36.             NSLog(@"error while getting short url - %@", error.localizedDescription);
  37.             [vc shareActionFinishedWithStatus:ShareActionFailedWithError];
  38.         }
  39.     }];
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top