Skip to content

Instantly share code, notes, and snippets.

View aaustin's full-sized avatar

Alex Austin aaustin

View GitHub Profile
Branch *branch = [Branch getInstance];
// Add this line to disable use of a hidden Safari View Controller
[branch disableCookieBasedMatching];
[branch initSession .....];
<script type="text/javascript">
(function(b,r,a,n,c,h,_,s,d,k){if(!b[n]||!b[n]._q){for(;s<_.length;)c(h,_[s++]);d=r.createElement(a);d.async=1;d.src="https://cdn.branch.io/branch-latest.min.js";k=r.getElementsByTagName(a)[0];k.parentNode.insertBefore(d,k);b[n]=h}})(window,document,"script","branch",function(b,r){b[r]=function(){b._q.push([r,arguments])}},{_q:[],_v:1},"addListener applyCode banner closeBanner creditHistory credits data deepview deepviewCta first getCode init link logout redeem referrals removeListener sendSMS setBranchViewData setIdentity track validateCode".split(" "), 0);
branch.init('BRANCH KEY', function(err, data) {
// callback to handle err or data
});
</script>
BranchUniversalObject *branchUniversalObject = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"image/12345];
branchUniversalObject.title = @"the internet vs a term paper";
branchUniversalObject.contentDescription = @"How I feel when I have a term paper due.;
branchUniversalObject.imageUrl = @"https://s3-us-west-1.amazonaws.com/branchhost/paper_internet.jpg";
[branchUniversalObject addMetadataKey:@"image_id" value:@"12345"];
// add additional og tags in metadata like so
[branchUniversalObject addMetadataKey:@"$og_type" value:@"image/jpeg"];
BranchUniversalObject *branchUniversalObject = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"image/12345];
branchUniversalObject.title = @"the internet vs a term paper";
branchUniversalObject.contentDescription = @"How I feel when I have a term paper due.;
branchUniversalObject.imageUrl = @"https://s3-us-west-1.amazonaws.com/branchhost/paper_internet.jpg";
[branchUniversalObject addMetadataKey:@"image_id" value:@"12345"];
BranchLinkProperties *linkProperties = [[BranchLinkProperties alloc] init];
linkProperties.feature = @"share";
[linkProperties addControlParam:@"$desktop_url" withValue:@"https://s3-us-west-1.amazonaws.com/branchhost/paper_internet.jpg"];
BranchLinkProperties *linkProperties = [[BranchLinkProperties alloc] init];
linkProperties.feature = @"sharing";
linkProperties.channel = @"facebook"; // make sure to specify the channel!
[linkProperties addControlParam:@"$desktop_url" withValue:@"http://example.com/video/12345"];
[branchUniversalObject getShortUrlWithLinkProperties:linkProperties andCallback:^(NSString *url, NSError *error) {
if (!error && url) {
// Drop the URL into your share message and let the user share it to the world
NSLog(@"success getting url! %@", url);
}
BranchLinkProperties *linkProperties = [[BranchLinkProperties alloc] init];
linkProperties.feature = @"share";
[linkProperties addControlParam:@"$desktop_url" withValue:@"http://example.com/video/12345"];
[branchUniversalObject showShareSheetWithLinkProperties:linkProperties
andShareText:@"Super amazing thing I want to share!"
fromViewController:self
andCallback:^{
NSLog(@"finished presenting");
}];
// canonical identifier is the unique identifier for the content or user being shared
BranchUniversalObject *branchUniversalObject = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"item/12345"];
branchUniversalObject.title = @"Awesome video";
branchUniversalObject.contentDescription = @"Check out this awesome video. It's hilarious.";
branchUniversalObject.imageUrl = @"https://example.com/video-12345.png";
[branchUniversalObject addMetadataKey:@"video_id" value:@"12345"];
[branchUniversalObject addMetadataKey:@"sharing_user_id" value:@"6789"];
[branchUniversalObject addMetadataKey:@"sharing_user_name" value:@"Bruce"];
Branch *branch = [Branch getInstance];
[branch setIdentity:@"logged_in_user@gmail.com"];
BranchUniversalObject *branchUniversalObject = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"sticker_id/12345"];
branchUniversalObject.title = @"This hilarious sticker";
branchUniversalObject.contentDescription = @"Check out this hilarious sticker in my sticker app, the best sticker app in the world.";
branchUniversalObject.imageUrl = @"https://mystickerapp.com/sticker-12345.png";
[branchUniversalObject addMetadataKey:@"sticker_id" value:@"12345"];
BranchLinkProperties *linkProperties = [[BranchLinkProperties alloc] init];
linkProperties.feature = @"sharing";
linkProperties.channel = @"imessage";