From 0109a9f3e8e22c911d3af22856780b89b9dbb466 Mon Sep 17 00:00:00 2001 From: Jared Sinclair Date: Thu, 3 Apr 2014 14:34:39 -0400 Subject: [PATCH 01/49] Update demo app for demo. --- .../Overshare/SampleTimelineViewController.m | 79 +++++++++---------- 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m index 563b4e3..ab90575 100644 --- a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m +++ b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m @@ -17,11 +17,11 @@ @interface SampleTimelineViewController () < - SampleTimelineCellDelegate, - OSKPresentationViewControllers, - OSKPresentationStyle, - OSKPresentationColor, - OSKXCallbackURLInfo +SampleTimelineCellDelegate, +OSKPresentationViewControllers, +OSKPresentationStyle, +OSKPresentationColor, +OSKXCallbackURLInfo > @property (assign, nonatomic) OSKActivitySheetViewControllerStyle sheetStyle; @@ -66,29 +66,42 @@ - (void)viewDidLoad { #pragma mark - Sharing + + + + + + + + + + + - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { - // 1) Create the shareable content from the user's source content. - - NSString *text = @"Me and my dad make models of clipper ships. #Clipperships sail on the ocean."; - NSArray *images = @[[UIImage imageNamed:@"soda.jpg"], - [UIImage imageNamed:@"rain.jpg"], - [UIImage imageNamed:@"type.jpg"]]; - NSString *canonicalURL = @"http://github.com/overshare/overshare-kit"; - NSString *authorName = @"testochango"; - - OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text - authorName:authorName - canonicalURL:canonicalURL - images:images]; + // 1) Grab the user's data that will be shared. + + // 2) Create the shareable content from the user's source data. - if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { - [self showShareSheet_Phone:content]; - } else { - [self showShareSheet_Pad_FromCell:tappedCell content:content]; - } + // 3) Present the activity sheet via the presentation manager. } + + + + + + + + + + + + + + + + - (void)showShareSheet_Pad_FromCell:(SampleTimelineCell *)tappedCell content:(OSKShareableContent *)content { [self setIPadPresentingIndexPath:[self.tableView indexPathForCell:tappedCell]]; @@ -99,7 +112,7 @@ - (void)showShareSheet_Pad_FromCell:(SampleTimelineCell *)tappedCell content:(OS // 3) Create the options dictionary. See OSKActivity.h for more options. NSDictionary *options = @{ OSKPresentationOption_ActivityCompletionHandler : completionHandler, - OSKPresentationOption_PresentationEndingHandler : dismissalHandler}; + OSKPresentationOption_PresentationEndingHandler : dismissalHandler}; // 4) Prep the iPad-specific presentation needs. CGRect presentationRect = [self presentationRectForCell:tappedCell]; @@ -132,22 +145,6 @@ - (void)showShareSheet_Pad_FromBarButtonItem:(UIBarButtonItem *)barButtonItem co options:options]; } -- (void)showShareSheet_Phone:(OSKShareableContent *)content { - - // 2) Setup optional completion and dismissal handlers - OSKActivityCompletionHandler completionHandler = [self activityCompletionHandler]; - OSKPresentationEndingHandler dismissalHandler = [self dismissalHandler]; - - // 3) Create the options dictionary. See OSKActivity.h for more options. - NSDictionary *options = @{ OSKPresentationOption_ActivityCompletionHandler : completionHandler, - OSKPresentationOption_PresentationEndingHandler : dismissalHandler}; - - // 4) Present the activity sheet via the presentation manager. - [[OSKPresentationManager sharedInstance] presentActivitySheetForContent:content - presentingViewController:self - options:options]; -} - #pragma mark - OSKActivitiesManager X-Callback-URL Delegate @@ -244,7 +241,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } -#pragma mark - SampleTimelineViewController +#pragma mark - SampleTimelineViewController - (void)accountManagerButtonTapped:(id)sender { [self showAccountsManagement]; From 52b85e1f7e7e9014c456e0d6b128a061d7e616a8 Mon Sep 17 00:00:00 2001 From: Jared Sinclair Date: Thu, 3 Apr 2014 15:14:55 -0400 Subject: [PATCH 02/49] Update demo. --- .../Overshare/SampleTimelineViewController.m | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m index ab90575..82870b2 100644 --- a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m +++ b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m @@ -80,10 +80,28 @@ - (void)viewDidLoad { - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { // 1) Grab the user's data that will be shared. + + NSString *text = @"Me and my dad make models of clipper ships. #Clipperships sail on the ocean."; + + NSArray *images = @[[UIImage imageNamed:@"soda.jpg"], + [UIImage imageNamed:@"rain.jpg"], + [UIImage imageNamed:@"type.jpg"]]; + + NSString *canonicalURL = @"http://github.com/overshare/overshare-kit"; + NSString *authorName = @"testochango"; // 2) Create the shareable content from the user's source data. + OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text + authorName:authorName + canonicalURL:canonicalURL + images:images]; + // 3) Present the activity sheet via the presentation manager. + + [[OSKPresentationManager sharedInstance] presentActivitySheetForContent:content + presentingViewController:self + options:nil]; } From 87593a9bbd623a53a2542d8fbcd17e7ec7bc987e Mon Sep 17 00:00:00 2001 From: Jared Sinclair Date: Mon, 7 Apr 2014 14:43:14 -0400 Subject: [PATCH 03/49] Tweak demo. --- Overshare Kit/OSKNavigationController.m | 16 ------- .../Overshare/SampleTimelineViewController.m | 44 +++++++------------ 2 files changed, 16 insertions(+), 44 deletions(-) diff --git a/Overshare Kit/OSKNavigationController.m b/Overshare Kit/OSKNavigationController.m index b8e25c2..a6674b8 100644 --- a/Overshare Kit/OSKNavigationController.m +++ b/Overshare Kit/OSKNavigationController.m @@ -73,28 +73,12 @@ - (void)setupUIAppearance { [[UIBarButtonItem appearanceWhenContainedIn:[OSKNavigationController class], nil] setBackgroundImage:barButtonImage_normal forState:UIControlStateNormal - style:UIBarButtonItemStyleBordered barMetrics:UIBarMetricsDefault]; [[UIBarButtonItem appearanceWhenContainedIn:[OSKNavigationController class], nil] setBackgroundImage:barButtonImage_highlighted forState:UIControlStateHighlighted - style:UIBarButtonItemStyleBordered barMetrics:UIBarMetricsDefault]; [[UIBarButtonItem appearanceWhenContainedIn:[OSKNavigationController class], nil] setBackgroundImage:barButtonImage_disabled forState:UIControlStateDisabled - style:UIBarButtonItemStyleBordered - barMetrics:UIBarMetricsDefault]; - - [[UIBarButtonItem appearanceWhenContainedIn:[OSKNavigationController class], nil] setBackgroundImage:barButtonImage_normal - forState:UIControlStateNormal - style:UIBarButtonItemStyleDone - barMetrics:UIBarMetricsDefault]; - [[UIBarButtonItem appearanceWhenContainedIn:[OSKNavigationController class], nil] setBackgroundImage:barButtonImage_highlighted - forState:UIControlStateHighlighted - style:UIBarButtonItemStyleDone - barMetrics:UIBarMetricsDefault]; - [[UIBarButtonItem appearanceWhenContainedIn:[OSKNavigationController class], nil] setBackgroundImage:barButtonImage_disabled - forState:UIControlStateDisabled - style:UIBarButtonItemStyleDone barMetrics:UIBarMetricsDefault]; } } diff --git a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m index 82870b2..45f9e71 100644 --- a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m +++ b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m @@ -64,18 +64,7 @@ - (void)viewDidLoad { } -#pragma mark - Sharing - - - - - - - - - - - +#pragma mark - Intro to Overshare Kit Demo - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { @@ -87,7 +76,7 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { [UIImage imageNamed:@"rain.jpg"], [UIImage imageNamed:@"type.jpg"]]; - NSString *canonicalURL = @"http://github.com/overshare/overshare-kit"; + NSString *canonicalURL = @"https://twitter.com/testochango/status/453193613900410881"; NSString *authorName = @"testochango"; // 2) Create the shareable content from the user's source data. @@ -105,20 +94,7 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { } - - - - - - - - - - - - - - +#pragma mark - Sharing - (void)showShareSheet_Pad_FromCell:(SampleTimelineCell *)tappedCell content:(OSKShareableContent *)content { @@ -190,10 +166,22 @@ - (OSKActivitySheetViewControllerStyle)osk_activitySheetStyle { } - (BOOL)osk_toolbarsUseUnjustifiablyBorderlessButtons { -#warning Override this to use bordered navigation bar buttons. +#warning Override this and return NO to enable bordered navigation bar buttons. return YES; } +/* +- (UIFontDescriptor *)osk_normalFontDescriptor { + NSDictionary *attributes = @{UIFontDescriptorNameAttribute : @"AvenirNext-Regular"}; + UIFontDescriptor *descriptor = [UIFontDescriptor fontDescriptorWithFontAttributes:attributes]; + return descriptor; +} +- (UIFontDescriptor *)osk_boldFontDescriptor { + NSDictionary *attributes = @{UIFontDescriptorNameAttribute : @"AvenirNext-Bold"}; + UIFontDescriptor *descriptor = [UIFontDescriptor fontDescriptorWithFontAttributes:attributes]; + return descriptor; +} +*/ #pragma mark - OSKPresentationManager Color Delegate From 5681b595b76c4a4b91b1e41dacfb638b44cbb375 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Wed, 21 Jan 2015 08:55:25 -0500 Subject: [PATCH 04/49] Set Version 1.0.0 --- OvershareKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OvershareKit.podspec b/OvershareKit.podspec index 066acd3..ea1e16b 100644 --- a/OvershareKit.podspec +++ b/OvershareKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OvershareKit" - s.version = "1.3.1" + s.version = "1.0.0" s.summary = "A soup-to-nuts sharing library for iOS." s.homepage = "https://github.com/overshare/overshare-kit" s.license = { :type => 'MIT', :file => 'LICENSE' } From ba0881dd27bd77269dff6ba8dc63328589fcf83a Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Wed, 21 Jan 2015 09:46:57 -0500 Subject: [PATCH 05/49] Adds Branch dependency in podspec --- OvershareKit.podspec | 1 + 1 file changed, 1 insertion(+) diff --git a/OvershareKit.podspec b/OvershareKit.podspec index ea1e16b..542912e 100644 --- a/OvershareKit.podspec +++ b/OvershareKit.podspec @@ -21,4 +21,5 @@ Pod::Spec.new do |s| s.dependency 'ADNLogin' s.dependency 'PocketAPI' + s.dependency 'Branch' end From 7b5953a6d93d592ddd71f1c1564493815c35136c Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Wed, 21 Jan 2015 09:57:00 -0500 Subject: [PATCH 06/49] Adds Branch SDK Submodule --- .gitmodules | 3 +++ Dependencies/Branch-iOS-SDK | 1 + 2 files changed, 4 insertions(+) create mode 160000 Dependencies/Branch-iOS-SDK diff --git a/.gitmodules b/.gitmodules index fc0b2bb..458f64f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,3 +5,6 @@ [submodule "ADNLogin-SDK-iOS"] path = Dependencies/ADNLogin-SDK url = https://github.com/appdotnet/ADNLogin-SDK-iOS.git +[submodule "Dependencies/Branch-iOS-SDK"] + path = Dependencies/Branch-iOS-SDK + url = https://github.com/BranchMetrics/Branch-iOS-SDK diff --git a/Dependencies/Branch-iOS-SDK b/Dependencies/Branch-iOS-SDK new file mode 160000 index 0000000..9ad7b8f --- /dev/null +++ b/Dependencies/Branch-iOS-SDK @@ -0,0 +1 @@ +Subproject commit 9ad7b8f0b03e3145c8f451b78ce224df99f3fcb6 From 004671c3873708d89d89645816706caccb51bce7 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Wed, 21 Jan 2015 09:58:52 -0500 Subject: [PATCH 07/49] Adds Branch iOS SDK to Workspace Closes #1 --- .../OvershareKit.xcodeproj/project.pbxproj | 82 +++++++++++++++++++ .../Overshare.xcodeproj/project.pbxproj | 76 +++++++++++++++++ 2 files changed, 158 insertions(+) diff --git a/Projects/Static Library/OvershareKit/OvershareKit.xcodeproj/project.pbxproj b/Projects/Static Library/OvershareKit/OvershareKit.xcodeproj/project.pbxproj index 13dc241..9785cf0 100644 --- a/Projects/Static Library/OvershareKit/OvershareKit.xcodeproj/project.pbxproj +++ b/Projects/Static Library/OvershareKit/OvershareKit.xcodeproj/project.pbxproj @@ -120,6 +120,16 @@ 8895C34C18A3BA6B000B7F28 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8895C34B18A3BA6B000B7F28 /* MediaPlayer.framework */; }; 8895C34E18A3BA70000B7F28 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8895C34D18A3BA70000B7F28 /* Security.framework */; }; 8895C35018A3BA78000B7F28 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8895C34F18A3BA78000B7F28 /* SystemConfiguration.framework */; }; + D24CF7471A6FF57F00540A64 /* BNCError.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF7331A6FF57F00540A64 /* BNCError.m */; }; + D24CF7481A6FF57F00540A64 /* BNCPreferenceHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF7351A6FF57F00540A64 /* BNCPreferenceHelper.m */; }; + D24CF7491A6FF57F00540A64 /* BNCServerInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF7371A6FF57F00540A64 /* BNCServerInterface.m */; }; + D24CF74A1A6FF57F00540A64 /* BNCServerRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF7391A6FF57F00540A64 /* BNCServerRequest.m */; }; + D24CF74B1A6FF57F00540A64 /* BNCServerRequestQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF73B1A6FF57F00540A64 /* BNCServerRequestQueue.m */; }; + D24CF74C1A6FF57F00540A64 /* BNCServerResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF73D1A6FF57F00540A64 /* BNCServerResponse.m */; }; + D24CF74D1A6FF57F00540A64 /* BNCSystemObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF73F1A6FF57F00540A64 /* BNCSystemObserver.m */; }; + D24CF74E1A6FF57F00540A64 /* Branch.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF7421A6FF57F00540A64 /* Branch.m */; }; + D24CF74F1A6FF57F00540A64 /* BranchServerInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF7441A6FF57F00540A64 /* BranchServerInterface.m */; }; + D24CF7501A6FF57F00540A64 /* UIViewController+BNCDebugging.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF7461A6FF57F00540A64 /* UIViewController+BNCDebugging.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -496,6 +506,28 @@ 8895C34B18A3BA6B000B7F28 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; }; 8895C34D18A3BA70000B7F28 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; 8895C34F18A3BA78000B7F28 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; + D24CF7311A6FF57F00540A64 /* BNCConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCConfig.h; sourceTree = ""; }; + D24CF7321A6FF57F00540A64 /* BNCError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCError.h; sourceTree = ""; }; + D24CF7331A6FF57F00540A64 /* BNCError.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCError.m; sourceTree = ""; }; + D24CF7341A6FF57F00540A64 /* BNCPreferenceHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCPreferenceHelper.h; sourceTree = ""; }; + D24CF7351A6FF57F00540A64 /* BNCPreferenceHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCPreferenceHelper.m; sourceTree = ""; }; + D24CF7361A6FF57F00540A64 /* BNCServerInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCServerInterface.h; sourceTree = ""; }; + D24CF7371A6FF57F00540A64 /* BNCServerInterface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCServerInterface.m; sourceTree = ""; }; + D24CF7381A6FF57F00540A64 /* BNCServerRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCServerRequest.h; sourceTree = ""; }; + D24CF7391A6FF57F00540A64 /* BNCServerRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCServerRequest.m; sourceTree = ""; }; + D24CF73A1A6FF57F00540A64 /* BNCServerRequestQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCServerRequestQueue.h; sourceTree = ""; }; + D24CF73B1A6FF57F00540A64 /* BNCServerRequestQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCServerRequestQueue.m; sourceTree = ""; }; + D24CF73C1A6FF57F00540A64 /* BNCServerResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCServerResponse.h; sourceTree = ""; }; + D24CF73D1A6FF57F00540A64 /* BNCServerResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCServerResponse.m; sourceTree = ""; }; + D24CF73E1A6FF57F00540A64 /* BNCSystemObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCSystemObserver.h; sourceTree = ""; }; + D24CF73F1A6FF57F00540A64 /* BNCSystemObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCSystemObserver.m; sourceTree = ""; }; + D24CF7401A6FF57F00540A64 /* Branch-SDK-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Branch-SDK-Prefix.pch"; sourceTree = ""; }; + D24CF7411A6FF57F00540A64 /* Branch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Branch.h; sourceTree = ""; }; + D24CF7421A6FF57F00540A64 /* Branch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Branch.m; sourceTree = ""; }; + D24CF7431A6FF57F00540A64 /* BranchServerInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BranchServerInterface.h; sourceTree = ""; }; + D24CF7441A6FF57F00540A64 /* BranchServerInterface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchServerInterface.m; sourceTree = ""; }; + D24CF7451A6FF57F00540A64 /* UIViewController+BNCDebugging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+BNCDebugging.h"; sourceTree = ""; }; + D24CF7461A6FF57F00540A64 /* UIViewController+BNCDebugging.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+BNCDebugging.m"; sourceTree = ""; }; F2ED4093BD3864F639BD9AB1 /* GooglePlus-Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "GooglePlus-Icon-76.png"; sourceTree = ""; }; F2ED4477173538D750DC8F83 /* GooglePlus-Icon-29.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "GooglePlus-Icon-29.png"; sourceTree = ""; }; F2ED44D42685E0B33F979699 /* GooglePlus-Icon-29@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "GooglePlus-Icon-29@2x.png"; sourceTree = ""; }; @@ -529,6 +561,7 @@ 7F6711F8181EDF870006E037 /* Third-Party Dependencies */ = { isa = PBXGroup; children = ( + D24CF7301A6FF57F00540A64 /* Branch-SDK */, 7F6711F9181EDF900006E037 /* ADNLogin */, 7F6711FA181EDF960006E037 /* Pocket */, ); @@ -964,6 +997,36 @@ path = Images; sourceTree = ""; }; + D24CF7301A6FF57F00540A64 /* Branch-SDK */ = { + isa = PBXGroup; + children = ( + D24CF7311A6FF57F00540A64 /* BNCConfig.h */, + D24CF7321A6FF57F00540A64 /* BNCError.h */, + D24CF7331A6FF57F00540A64 /* BNCError.m */, + D24CF7341A6FF57F00540A64 /* BNCPreferenceHelper.h */, + D24CF7351A6FF57F00540A64 /* BNCPreferenceHelper.m */, + D24CF7361A6FF57F00540A64 /* BNCServerInterface.h */, + D24CF7371A6FF57F00540A64 /* BNCServerInterface.m */, + D24CF7381A6FF57F00540A64 /* BNCServerRequest.h */, + D24CF7391A6FF57F00540A64 /* BNCServerRequest.m */, + D24CF73A1A6FF57F00540A64 /* BNCServerRequestQueue.h */, + D24CF73B1A6FF57F00540A64 /* BNCServerRequestQueue.m */, + D24CF73C1A6FF57F00540A64 /* BNCServerResponse.h */, + D24CF73D1A6FF57F00540A64 /* BNCServerResponse.m */, + D24CF73E1A6FF57F00540A64 /* BNCSystemObserver.h */, + D24CF73F1A6FF57F00540A64 /* BNCSystemObserver.m */, + D24CF7401A6FF57F00540A64 /* Branch-SDK-Prefix.pch */, + D24CF7411A6FF57F00540A64 /* Branch.h */, + D24CF7421A6FF57F00540A64 /* Branch.m */, + D24CF7431A6FF57F00540A64 /* BranchServerInterface.h */, + D24CF7441A6FF57F00540A64 /* BranchServerInterface.m */, + D24CF7451A6FF57F00540A64 /* UIViewController+BNCDebugging.h */, + D24CF7461A6FF57F00540A64 /* UIViewController+BNCDebugging.m */, + ); + name = "Branch-SDK"; + path = "../../../../Branch-iOS-SDK/Branch-SDK/Branch-SDK"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -999,6 +1062,7 @@ hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = 7FEE7661181ED867000F684A; productRefGroup = 7FEE766B181ED867000F684A /* Products */; @@ -1019,6 +1083,7 @@ 7F75BEFE1821539700D3681E /* OSKAccountManagementViewController.m in Sources */, 7FEE78C8181ED8FE000F684A /* OSKAppDotNetActivity.m in Sources */, 7FEE78F6181ED8FE000F684A /* OSKUsernamePasswordViewController.m in Sources */, + D24CF7501A6FF57F00540A64 /* UIViewController+BNCDebugging.m in Sources */, 7FEE78BE181ED8FE000F684A /* OSKActivityCollectionViewCell.m in Sources */, 7FEE78D1181ED8FE000F684A /* OSKFileManager.m in Sources */, 7FEE78F7181ED8FE000F684A /* OSKWebViewController.m in Sources */, @@ -1026,6 +1091,7 @@ 7FEE78E2181ED8FE000F684A /* OSKPagedHorizontalLayout.m in Sources */, 7FEE78C2181ED8FE000F684A /* OSKActivityOperation.m in Sources */, 7FEE78DA181ED8FE000F684A /* OSKManagedAccount.m in Sources */, + D24CF74A1A6FF57F00540A64 /* BNCServerRequest.m in Sources */, 7FA91AF71889F61D00A5DF9B /* OSKReadingListActivity.m in Sources */, 7FEE78E6181ED8FE000F684A /* OSKPresentationManager.m in Sources */, 7F55A30E18425C6C004A3BCC /* OSKSessionController_Phone.m in Sources */, @@ -1045,6 +1111,7 @@ 7FEE78D9181ED8FE000F684A /* OSKMailComposeViewController.m in Sources */, 7F55A30C18425C6C004A3BCC /* OSKSession.m in Sources */, 7FEE78F9181ED8FE000F684A /* UIDevice+OSKHardware.m in Sources */, + D24CF74C1A6FF57F00540A64 /* BNCServerResponse.m in Sources */, 7FEE78EE181ED8FE000F684A /* OSKSystemAccountStore.m in Sources */, 7FEE78C9181ED8FE000F684A /* OSKAppDotNetAuthenticationViewController.m in Sources */, 7FEE78C3181ED8FE000F684A /* OSKActivitySheetViewController.m in Sources */, @@ -1057,10 +1124,12 @@ 7FEE78DB181ED8FE000F684A /* OSKManagedAccountCredential.m in Sources */, 7FEE78F2181ED8FE000F684A /* OSKTwitterText.m in Sources */, 7FEE78BB181ED8FE000F684A /* OSKActionSheet.m in Sources */, + D24CF7491A6FF57F00540A64 /* BNCServerInterface.m in Sources */, 7FEE78F4181ED8FE000F684A /* OSKTwitterUtility.m in Sources */, 32C2B9B7190337BC0055C98B /* OSKMimeAttachment.m in Sources */, 7FEE78B3181ED8FE000F684A /* NSHTTPURLResponse+OSKUtilities.m in Sources */, 7FEE78F3181ED8FE000F684A /* OSKTwitterTextEntity.m in Sources */, + D24CF74B1A6FF57F00540A64 /* BNCServerRequestQueue.m in Sources */, 7FEE78B2181ED8FE000F684A /* NSDictionary+OSKModel.m in Sources */, 7FEE78F5181ED8FE000F684A /* OSKUsernamePasswordCell.m in Sources */, 7FEE78BA181ED8FE000F684A /* OSKAccountChooserViewController.m in Sources */, @@ -1079,13 +1148,17 @@ 7FEE78C6181ED8FE000F684A /* OSKAirDropViewController.m in Sources */, 7F55A30D18425C6C004A3BCC /* OSKSessionController_Pad.m in Sources */, 7F75BF001821539700D3681E /* OSKPocketAccountViewController.m in Sources */, + D24CF7471A6FF57F00540A64 /* BNCError.m in Sources */, 7FEE78B5181ED8FE000F684A /* NSString+OSK_UUID.m in Sources */, + D24CF74F1A6FF57F00540A64 /* BranchServerInterface.m in Sources */, + D24CF74D1A6FF57F00540A64 /* BNCSystemObserver.m in Sources */, 7FEE78B9181ED8FE000F684A /* OSK1PasswordSearchActivity.m in Sources */, 7F1DA9E0183C6B050082356D /* OSKLinkShorteningUtility.m in Sources */, 7FEE7675181ED867000F684A /* OvershareKit.m in Sources */, 7FEE78DE181ED8FE000F684A /* OSKMicroblogPublishingViewController.m in Sources */, 7FEE78C5181ED8FE000F684A /* OSKAirDropActivity.m in Sources */, 7FEE78DC181ED8FE000F684A /* OSKManagedAccountStore.m in Sources */, + D24CF7481A6FF57F00540A64 /* BNCPreferenceHelper.m in Sources */, 7FEE78CA181ED8FE000F684A /* OSKAppDotNetUtility.m in Sources */, 7FEE78D7181ED8FE000F684A /* OSKInstapaperUtility.m in Sources */, 7FEE78CE181ED8FE000F684A /* OSKCopyToPasteboardActivity.m in Sources */, @@ -1107,6 +1180,7 @@ 7FE4109F1821994B00B13AB1 /* OSKFacebookPublishingViewController.m in Sources */, 7FEE78B4181ED8FE000F684A /* NSMutableURLRequest+OSKUtilities.m in Sources */, 7FEE78EC181ED8FE000F684A /* OSKShareableContentItem.m in Sources */, + D24CF74E1A6FF57F00540A64 /* Branch.m in Sources */, 7FEE78E5181ED8FE000F684A /* OSKPocketActivity.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1188,6 +1262,10 @@ isa = XCBuildConfiguration; buildSettings = { DSTROOT = /tmp/OvershareKit.dst; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "/Users/scott/Code/ObjC/overshare-deeplinking-kit/Dependencies/Branch-iOS-SDK", + ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "OvershareKit/OvershareKit-Prefix.pch"; OTHER_LDFLAGS = "-ObjC"; @@ -1200,6 +1278,10 @@ isa = XCBuildConfiguration; buildSettings = { DSTROOT = /tmp/OvershareKit.dst; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "/Users/scott/Code/ObjC/overshare-deeplinking-kit/Dependencies/Branch-iOS-SDK", + ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "OvershareKit/OvershareKit-Prefix.pch"; OTHER_LDFLAGS = "-ObjC"; diff --git a/Projects/iOS App/Overshare/Overshare.xcodeproj/project.pbxproj b/Projects/iOS App/Overshare/Overshare.xcodeproj/project.pbxproj index 9323c95..547ca5b 100644 --- a/Projects/iOS App/Overshare/Overshare.xcodeproj/project.pbxproj +++ b/Projects/iOS App/Overshare/Overshare.xcodeproj/project.pbxproj @@ -258,6 +258,16 @@ 8895C33E18A3BA1B000B7F28 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8895C33D18A3BA1B000B7F28 /* Security.framework */; }; 8895C34018A3BA24000B7F28 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8895C33F18A3BA24000B7F28 /* SystemConfiguration.framework */; }; 8895C35218A3BFA2000B7F28 /* Icon-60@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8895C35118A3BFA2000B7F28 /* Icon-60@2x.png */; }; + D24CF7261A6FF57000540A64 /* BNCError.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF7121A6FF57000540A64 /* BNCError.m */; }; + D24CF7271A6FF57000540A64 /* BNCPreferenceHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF7141A6FF57000540A64 /* BNCPreferenceHelper.m */; }; + D24CF7281A6FF57000540A64 /* BNCServerInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF7161A6FF57000540A64 /* BNCServerInterface.m */; }; + D24CF7291A6FF57000540A64 /* BNCServerRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF7181A6FF57000540A64 /* BNCServerRequest.m */; }; + D24CF72A1A6FF57000540A64 /* BNCServerRequestQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF71A1A6FF57000540A64 /* BNCServerRequestQueue.m */; }; + D24CF72B1A6FF57000540A64 /* BNCServerResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF71C1A6FF57000540A64 /* BNCServerResponse.m */; }; + D24CF72C1A6FF57000540A64 /* BNCSystemObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF71E1A6FF57000540A64 /* BNCSystemObserver.m */; }; + D24CF72D1A6FF57000540A64 /* Branch.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF7211A6FF57000540A64 /* Branch.m */; }; + D24CF72E1A6FF57000540A64 /* BranchServerInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF7231A6FF57000540A64 /* BranchServerInterface.m */; }; + D24CF72F1A6FF57000540A64 /* UIViewController+BNCDebugging.m in Sources */ = {isa = PBXBuildFile; fileRef = D24CF7251A6FF57000540A64 /* UIViewController+BNCDebugging.m */; }; F2ED44FF27CCD7E9F8A34E77 /* GooglePlus-Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = F2ED4DB1EC62FB9EF52F15D0 /* GooglePlus-Icon-76.png */; }; F2ED453AABB8833C66910E03 /* GooglePlus-Icon-76@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F2ED46B9E187F11BFEF64BF2 /* GooglePlus-Icon-76@2x.png */; }; F2ED4696B1DB571FBBE9204A /* GooglePlus-Icon-60@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F2ED40569B315A0A210DC081 /* GooglePlus-Icon-60@2x.png */; }; @@ -655,6 +665,28 @@ 8895C33D18A3BA1B000B7F28 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; 8895C33F18A3BA24000B7F28 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; 8895C35118A3BFA2000B7F28 /* Icon-60@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-60@2x.png"; path = "Overshare/Icon-60@2x.png"; sourceTree = ""; }; + D24CF7101A6FF57000540A64 /* BNCConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCConfig.h; sourceTree = ""; }; + D24CF7111A6FF57000540A64 /* BNCError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCError.h; sourceTree = ""; }; + D24CF7121A6FF57000540A64 /* BNCError.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCError.m; sourceTree = ""; }; + D24CF7131A6FF57000540A64 /* BNCPreferenceHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCPreferenceHelper.h; sourceTree = ""; }; + D24CF7141A6FF57000540A64 /* BNCPreferenceHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCPreferenceHelper.m; sourceTree = ""; }; + D24CF7151A6FF57000540A64 /* BNCServerInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCServerInterface.h; sourceTree = ""; }; + D24CF7161A6FF57000540A64 /* BNCServerInterface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCServerInterface.m; sourceTree = ""; }; + D24CF7171A6FF57000540A64 /* BNCServerRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCServerRequest.h; sourceTree = ""; }; + D24CF7181A6FF57000540A64 /* BNCServerRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCServerRequest.m; sourceTree = ""; }; + D24CF7191A6FF57000540A64 /* BNCServerRequestQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCServerRequestQueue.h; sourceTree = ""; }; + D24CF71A1A6FF57000540A64 /* BNCServerRequestQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCServerRequestQueue.m; sourceTree = ""; }; + D24CF71B1A6FF57000540A64 /* BNCServerResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCServerResponse.h; sourceTree = ""; }; + D24CF71C1A6FF57000540A64 /* BNCServerResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCServerResponse.m; sourceTree = ""; }; + D24CF71D1A6FF57000540A64 /* BNCSystemObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNCSystemObserver.h; sourceTree = ""; }; + D24CF71E1A6FF57000540A64 /* BNCSystemObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNCSystemObserver.m; sourceTree = ""; }; + D24CF71F1A6FF57000540A64 /* Branch-SDK-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Branch-SDK-Prefix.pch"; sourceTree = ""; }; + D24CF7201A6FF57000540A64 /* Branch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Branch.h; sourceTree = ""; }; + D24CF7211A6FF57000540A64 /* Branch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Branch.m; sourceTree = ""; }; + D24CF7221A6FF57000540A64 /* BranchServerInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BranchServerInterface.h; sourceTree = ""; }; + D24CF7231A6FF57000540A64 /* BranchServerInterface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchServerInterface.m; sourceTree = ""; }; + D24CF7241A6FF57000540A64 /* UIViewController+BNCDebugging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+BNCDebugging.h"; sourceTree = ""; }; + D24CF7251A6FF57000540A64 /* UIViewController+BNCDebugging.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+BNCDebugging.m"; sourceTree = ""; }; F2ED40569B315A0A210DC081 /* GooglePlus-Icon-60@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "GooglePlus-Icon-60@2x.png"; sourceTree = ""; }; F2ED41960B167BFC3B93056A /* GooglePlus-Icon-29@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "GooglePlus-Icon-29@2x.png"; sourceTree = ""; }; F2ED429BFCE742838350E97F /* OSKGooglePlusActivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OSKGooglePlusActivity.m; sourceTree = ""; }; @@ -1473,6 +1505,7 @@ 7FEE7922181EDC71000F684A /* Third-Party Dependencies */ = { isa = PBXGroup; children = ( + D24CF70F1A6FF57000540A64 /* Branch-SDK */, 7FEE7924181EDC88000F684A /* ADNLogin */, 7FEE7923181EDC84000F684A /* Pocket */, ); @@ -1516,6 +1549,36 @@ name = GooglePlus; sourceTree = ""; }; + D24CF70F1A6FF57000540A64 /* Branch-SDK */ = { + isa = PBXGroup; + children = ( + D24CF7101A6FF57000540A64 /* BNCConfig.h */, + D24CF7111A6FF57000540A64 /* BNCError.h */, + D24CF7121A6FF57000540A64 /* BNCError.m */, + D24CF7131A6FF57000540A64 /* BNCPreferenceHelper.h */, + D24CF7141A6FF57000540A64 /* BNCPreferenceHelper.m */, + D24CF7151A6FF57000540A64 /* BNCServerInterface.h */, + D24CF7161A6FF57000540A64 /* BNCServerInterface.m */, + D24CF7171A6FF57000540A64 /* BNCServerRequest.h */, + D24CF7181A6FF57000540A64 /* BNCServerRequest.m */, + D24CF7191A6FF57000540A64 /* BNCServerRequestQueue.h */, + D24CF71A1A6FF57000540A64 /* BNCServerRequestQueue.m */, + D24CF71B1A6FF57000540A64 /* BNCServerResponse.h */, + D24CF71C1A6FF57000540A64 /* BNCServerResponse.m */, + D24CF71D1A6FF57000540A64 /* BNCSystemObserver.h */, + D24CF71E1A6FF57000540A64 /* BNCSystemObserver.m */, + D24CF71F1A6FF57000540A64 /* Branch-SDK-Prefix.pch */, + D24CF7201A6FF57000540A64 /* Branch.h */, + D24CF7211A6FF57000540A64 /* Branch.m */, + D24CF7221A6FF57000540A64 /* BranchServerInterface.h */, + D24CF7231A6FF57000540A64 /* BranchServerInterface.m */, + D24CF7241A6FF57000540A64 /* UIViewController+BNCDebugging.h */, + D24CF7251A6FF57000540A64 /* UIViewController+BNCDebugging.m */, + ); + name = "Branch-SDK"; + path = "../../../Dependencies/Branch-iOS-SDK/Branch-SDK/Branch-SDK"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -1557,6 +1620,7 @@ hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = 7FEE7626181ED83D000F684A; productRefGroup = 7FEE7630181ED83D000F684A /* Products */; @@ -1722,9 +1786,11 @@ 7FEE7790181ED8EF000F684A /* NSMutableURLRequest+OSKUtilities.m in Sources */, 7FEE77C5181ED8EF000F684A /* OSKPocketActivity.m in Sources */, 7FEE77B6181ED8EF000F684A /* OSKInstapaperUtility.m in Sources */, + D24CF7291A6FF57000540A64 /* BNCServerRequest.m in Sources */, 7F55A30118425C46004A3BCC /* OSKSessionController_Phone.m in Sources */, 7FEE7643181ED83D000F684A /* OSKAppDelegate.m in Sources */, 7FEE77AD181ED8EF000F684A /* OSKCopyToPasteboardActivity.m in Sources */, + D24CF7261A6FF57000540A64 /* BNCError.m in Sources */, 7FEE77B4181ED8EF000F684A /* OSKInMemoryImageCache.m in Sources */, 7FEE77A3181ED8EF000F684A /* OSKADNLoginManager.m in Sources */, 7F75BF3D1821588700D3681E /* PocketAPI.m in Sources */, @@ -1760,7 +1826,9 @@ 7FEE7797181ED8EF000F684A /* OSKActionSheet.m in Sources */, 7F78E9AC1820E5630042CF02 /* OSKPocketAccountViewController.m in Sources */, 7FEE77AE181ED8EF000F684A /* OSKEmailActivity.m in Sources */, + D24CF7281A6FF57000540A64 /* BNCServerInterface.m in Sources */, 7F14C95918DB5DBC00E635FE /* OSKTextViewAttachmentView.m in Sources */, + D24CF72D1A6FF57000540A64 /* Branch.m in Sources */, 7F14C95F18DB651800E635FE /* OSKCursorMovement.m in Sources */, 7FEE77B7181ED8EF000F684A /* OSKKeychainUtility.m in Sources */, 7FE467391821F4010054D2BC /* OSKAccountTypeCell.m in Sources */, @@ -1768,6 +1836,7 @@ 7FD649DA1895C7CA0021BD50 /* OSKDraftsActivity.m in Sources */, 7F75BF3E1821588700D3681E /* PocketAPILogin.m in Sources */, 7FEE77C7181ED8EF000F684A /* OSKReadabilityActivity.m in Sources */, + D24CF72B1A6FF57000540A64 /* BNCServerResponse.m in Sources */, 7F55A30218425C46004A3BCC /* OSKSessionController.m in Sources */, 7FEE77C1181ED8EF000F684A /* OSKOmnifocusActivity.m in Sources */, 7FEE7794181ED8EF000F684A /* OSK1PasswordBrowserActivity.m in Sources */, @@ -1808,21 +1877,26 @@ 7FEE77D8181ED8EF000F684A /* UIColor+OSKUtility.m in Sources */, 7FEE77A4181ED8EF000F684A /* OSKAirDropActivity.m in Sources */, 7F75BF3F1821588700D3681E /* PocketAPIOperation.m in Sources */, + D24CF72A1A6FF57000540A64 /* BNCServerRequestQueue.m in Sources */, 7FEE77A7181ED8EF000F684A /* OSKAppDotNetActivity.m in Sources */, 7FEE7798181ED8EF000F684A /* OSKActivitiesManager.m in Sources */, 7FEE77D3181ED8EF000F684A /* OSKTwitterTextEntity.m in Sources */, 7FEE77BF181ED8EF000F684A /* OSKNavigationController.m in Sources */, 7FEE77D7181ED8EF000F684A /* OSKWebViewController.m in Sources */, 7FEE77A0181ED8EF000F684A /* OSKActivityOperation.m in Sources */, + D24CF72F1A6FF57000540A64 /* UIViewController+BNCDebugging.m in Sources */, 7FEE77A9181ED8EF000F684A /* OSKAppDotNetUtility.m in Sources */, 7F55A30018425C46004A3BCC /* OSKSessionController_Pad.m in Sources */, 7FEE77C9181ED8EF000F684A /* OSKRPSTPasswordManagementAppService.m in Sources */, + D24CF72E1A6FF57000540A64 /* BranchServerInterface.m in Sources */, 7FEE77AC181ED8EF000F684A /* OSKChromeActivity.m in Sources */, 7FEE7795181ED8EF000F684A /* OSK1PasswordSearchActivity.m in Sources */, 7F55A2FF18425C46004A3BCC /* OSKSession.m in Sources */, + D24CF72C1A6FF57000540A64 /* BNCSystemObserver.m in Sources */, 7FEE77D2181ED8EF000F684A /* OSKTwitterText.m in Sources */, 7FEE7799181ED8EF000F684A /* OSKActivity.m in Sources */, 7FEE77C2181ED8EF000F684A /* OSKPagedHorizontalLayout.m in Sources */, + D24CF7271A6FF57000540A64 /* BNCPreferenceHelper.m in Sources */, 7FEE77C8181ED8EF000F684A /* OSKReadabilityUtility.m in Sources */, 7FEE77D6181ED8EF000F684A /* OSKUsernamePasswordViewController.m in Sources */, 7FEE77AB181ED8EF000F684A /* OSKBorderedButton.m in Sources */, @@ -1927,6 +2001,7 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "../../../Dependencies/GooglePlus-SDK", + "/Users/scott/Code/ObjC/overshare-deeplinking-kit/Dependencies/Branch-iOS-SDK", ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Overshare/Overshare-Prefix.pch"; @@ -1949,6 +2024,7 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "../../../Dependencies/GooglePlus-SDK", + "/Users/scott/Code/ObjC/overshare-deeplinking-kit/Dependencies/Branch-iOS-SDK", ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Overshare/Overshare-Prefix.pch"; From 0cdab375889e34d4aba1c769946d77d5ee9bfd13 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Wed, 21 Jan 2015 10:19:45 -0500 Subject: [PATCH 08/49] Adds Branch API Key in plist closes #2 --- Projects/iOS App/Overshare/Overshare/Overshare-Info.plist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Projects/iOS App/Overshare/Overshare/Overshare-Info.plist b/Projects/iOS App/Overshare/Overshare/Overshare-Info.plist index 25826cc..a5dd7ad 100644 --- a/Projects/iOS App/Overshare/Overshare/Overshare-Info.plist +++ b/Projects/iOS App/Overshare/Overshare/Overshare-Info.plist @@ -90,5 +90,7 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + bnc_app_key + 84499351119855798 From 658e5d6b0ed3d3a1af6d9cdaaf663b24f087249d Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Wed, 21 Jan 2015 12:31:22 -0500 Subject: [PATCH 09/49] Calls initSession in app delegate --- .../Overshare/Overshare/OSKAppDelegate.m | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m index 8fb91c9..c53f187 100644 --- a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m +++ b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m @@ -13,6 +13,7 @@ #import "PocketAPI.h" #import "SampleTimelineViewController.h" +#import "Branch.h" @implementation OSKAppDelegate @@ -21,6 +22,41 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( #warning You must replace this key with your own app's key! [[PocketAPI sharedAPI] setConsumerKey:@"19568-eab36ebc89e751893a754475"]; +#warning You must set your own Branch API key in Overshare-Info.plist as bnc_app_key (String). Find it here: https://dashboard.branch.io/#/settings + // Initialize Branch SDK + /* + http://branch.io + Branch enables custom downloads for every new user. + Drive higher conversions and more engagement using deep links that pass data through install and open. + + 1. Track how many installs/opens come from each shared link. + 2. Calculate viral kFactor + 3. Insight into which share channels are driving the most downloads: Facebook, Twitter, etc. + 4. Insight and analytics on which users are you rbiggest influencers and driving the most downloads. + 5. Embed custom dictionaries that live on through clicking a link - even through the app store - to build a customized experience for each new user and make it really easy to deep link. + 6. Customize links with OG tags to display content in Facebook, Twitter, etc. + 7. Reward new or reffering users! Power the link with referral tracking, reward attribution, and credit balance! + */ + + // A Pointer to the signleton instance of Branch. The first time this is called in the app lifecycle, a Branch instance is synchronously instatiated. + Branch *branch = [Branch getInstance]; + +#ifdef DEBUG + [Branch setDebug]; +#endif + + // Initiates a Branch session, and registers a callback. If you created a custom link with your own custom dictionary data, you probably want to know when the user session init finishes, so you can check that data. Think of this callback as your "deep link router". If your app opens with some data, you want to route the user depending on the data you passed in. Otherwise, send them to a generic install flow. + [branch initSessionWithLaunchOptions:launchOptions isReferrable:YES andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) { + if (!error) { + NSLog(@"finished init with params = %@", [params description]); + + // example dictionary data + // NSString *name = [params objectForKey:@"user"]; + // NSString *profileUrl = [params objectForKey:@"profile_pic"]; + // NSString *description = [params objectForKey:@"description"]; + } + }]; + UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [self setWindow:window]; @@ -62,7 +98,9 @@ - (void)applicationWillTerminate:(UIApplication *)application #warning Don't forget to override this method so that Pocket, App.net and Google+ authentication have the opportunity to respond! - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { + BOOL success = NO; + if ([[OSKADNLoginManager sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation]) { success = YES; } @@ -72,6 +110,13 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl else if ([GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation]) { success = YES; } + // Branch deep link handeler + // pass the url to the handle deep link call + // if handleDeepLink returns YES, and you registered a callback in initSessionAndRegisterDeepLinkHandler, the callback will be called with the data associated with the deep link + else if (![[Branch getInstance] handleDeepLink:url]) { + success = YES; + // do other deep link routing for the Facebook SDK, Pinterest SDK, etc + } else { // if you handle your own custom url-schemes, do it here // success = whatever; From 0cc6e8c89ca7cca3d4179c434678762940205b95 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Wed, 21 Jan 2015 13:00:25 -0500 Subject: [PATCH 10/49] Add link to branch read --- Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m index c53f187..75efb46 100644 --- a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m +++ b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m @@ -36,6 +36,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( 5. Embed custom dictionaries that live on through clicking a link - even through the app store - to build a customized experience for each new user and make it really easy to deep link. 6. Customize links with OG tags to display content in Facebook, Twitter, etc. 7. Reward new or reffering users! Power the link with referral tracking, reward attribution, and credit balance! + + For full documentation, see README.md in https://github.com/BranchMetrics/Branch-iOS-SDK */ // A Pointer to the signleton instance of Branch. The first time this is called in the app lifecycle, a Branch instance is synchronously instatiated. From c1725172a233183d52a31a430db1e19c8f9e02e2 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Wed, 21 Jan 2015 13:09:03 -0500 Subject: [PATCH 11/49] Update README.md for Branch info --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5716eca..912a422 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ OvershareKit makes it trivial to add rich sharing options to your iOS apps. In a - Built-in integration with popular third-party services like App.net, Instapaper, and more. +- Built-in integration with Branch.io, enabling custom downloads for every new user. + - Complete multi-account management, including authentication and storing credentials securely in the Keychain. - Killer text editing views with as-you-type Twitter syntax highlighting, [Riposte](http://riposteapp.net)-style swipe gesture cursor navigation, and automatic smart quotes. @@ -127,6 +129,8 @@ The list of services currently requiring application credentials are: - **Google Plus:** You'll need to obtain an application key by registering your app with Google Plus. +- **Branch:** Branch enables custom downloads for every new user. Visit http://branch.io for more information. You'll need to obtain an API key by registering your app with Branch. + If you have any questions about this setup process, don’t hesitate to [ask]. ### URL Schemes @@ -139,12 +143,14 @@ If you have any questions about this setup process, don’t hesitate to [ask]. OvershareKit is almost entirely a standalone library. All of its categories and classes have been properly namespaced with the `OSK` prefix to avoid collisions. -There are two required external libraries, which are included as git submodules in the Depedencies directory: +There are three required external libraries, which are included as git submodules in the Depedencies directory: - [App.net Login SDK](https://github.com/appdotnet/ADNLogin-SDK-iOS) - [Pocket-iOS-SDK](https://github.com/Pocket/Pocket-ObjC-SDK) +- [Branch-iOS-SDK](https://github.com/BranchMetrics/Branch-iOS-SDK) + *The Google Plus framework in the Dependencies directory is not a submodule.* From 41cea981202c1180c529465a647e5c76a368f33b Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Wed, 21 Jan 2015 14:59:27 -0500 Subject: [PATCH 12/49] Conditional initiation of Branch SDK --- .../Overshare/Overshare/OSKAppDelegate.m | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m index 75efb46..40a5ee5 100644 --- a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m +++ b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m @@ -13,7 +13,10 @@ #import "PocketAPI.h" #import "SampleTimelineViewController.h" + +// Include Branch, and Branch preference helper #import "Branch.h" +#import "BNCPreferenceHelper.h" @implementation OSKAppDelegate @@ -40,24 +43,28 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( For full documentation, see README.md in https://github.com/BranchMetrics/Branch-iOS-SDK */ - // A Pointer to the signleton instance of Branch. The first time this is called in the app lifecycle, a Branch instance is synchronously instatiated. - Branch *branch = [Branch getInstance]; + // Only initiate Branch if API key is defined in plist + if (![@"bnc_no_value" isEqualToString:[BNCPreferenceHelper getAppKey]]) { + // A Pointer to the signleton instance of Branch. The first time this is called in the app lifecycle, a Branch instance is synchronously instatiated. + Branch *branch = [Branch getInstance]; #ifdef DEBUG - [Branch setDebug]; + // Verbose logs for debugging + [Branch setDebug]; #endif - // Initiates a Branch session, and registers a callback. If you created a custom link with your own custom dictionary data, you probably want to know when the user session init finishes, so you can check that data. Think of this callback as your "deep link router". If your app opens with some data, you want to route the user depending on the data you passed in. Otherwise, send them to a generic install flow. - [branch initSessionWithLaunchOptions:launchOptions isReferrable:YES andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) { - if (!error) { - NSLog(@"finished init with params = %@", [params description]); - - // example dictionary data - // NSString *name = [params objectForKey:@"user"]; - // NSString *profileUrl = [params objectForKey:@"profile_pic"]; - // NSString *description = [params objectForKey:@"description"]; - } - }]; + // Initiates a Branch session, and registers a callback. If you created a custom link with your own custom dictionary data, you probably want to know when the user session init finishes, so you can check that data. Think of this callback as your "deep link router". If your app opens with some data, you want to route the user depending on the data you passed in. Otherwise, send them to a generic install flow. + [branch initSessionWithLaunchOptions:launchOptions isReferrable:YES andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) { + if (!error) { + NSLog(@"finished init with params = %@", [params description]); + + // example dictionary data + // NSString *name = [params objectForKey:@"user"]; + // NSString *profileUrl = [params objectForKey:@"profile_pic"]; + // NSString *description = [params objectForKey:@"description"]; + } + }]; + } UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [self setWindow:window]; From 1c4c5cbb4a6801a3d4b841bc30e8522224ec5368 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Wed, 21 Jan 2015 21:27:01 -0500 Subject: [PATCH 13/49] Initial logic for URL processing Conditional detection of url attribute based on type of content. Detection of multiple URLs in a string for something like a tweet or blog post. --- Overshare Kit/OSKShareableContent.m | 11 +++ Overshare Kit/OSKShareableContentItem.h | 10 +++ Overshare Kit/OSKShareableContentItem.m | 91 +++++++++++++++++++++++++ 3 files changed, 112 insertions(+) diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index 84a954f..cc54abc 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -141,21 +141,25 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * // Image posts cannot be link posts and vice versa. facebook.images = images; } + [facebook setBranchUrl]; content.facebookItem = facebook; OSKMicroblogPostContentItem *microblogPost = [[OSKMicroblogPostContentItem alloc] init]; microblogPost.text = [NSString stringWithFormat:@"“%@” (Via @%@) %@ ", text, authorName, canonicalURL]; microblogPost.images = images; + [microblogPost setBranchUrl]; content.microblogPostItem = microblogPost; OSKCopyToPasteboardContentItem *copyTextToPasteboard = [[OSKCopyToPasteboardContentItem alloc] init]; copyTextToPasteboard.text = text; copyTextToPasteboard.alternateActivityName = @"Copy Text"; + [copyTextToPasteboard setBranchUrl]; content.pasteboardItem = copyTextToPasteboard; OSKCopyToPasteboardContentItem *copyURLToPasteboard = [[OSKCopyToPasteboardContentItem alloc] init]; copyURLToPasteboard.text = canonicalURL; copyURLToPasteboard.alternateActivityName = @"Copy URL"; + [copyURLToPasteboard setBranchUrl]; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { copyURLToPasteboard.alternateActivityIcon = [UIImage imageNamed:@"osk-copyIcon-purple-76.png"]; } else { @@ -168,11 +172,13 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * emailItem.body = [NSString stringWithFormat:@"“%@”\n\n(Via @%@)\n\n%@ ", text, authorName, canonicalURL]; emailItem.subject = @"Clipper Ships Sail On the Ocean"; emailItem.attachments = images.copy; + [emailItem setBranchUrl]; content.emailItem = emailItem; OSKSMSContentItem *smsItem = [[OSKSMSContentItem alloc] init]; smsItem.body = microblogPost.text; smsItem.attachments = images; + [smsItem setBranchUrl]; content.smsItem = smsItem; if (URLforCanonicalURL) { @@ -180,6 +186,7 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * readLater.url = URLforCanonicalURL; readLater.title = [NSString stringWithFormat:@"Post by %@", authorName]; readLater.itemDescription = text; + [readLater setBranchUrl]; content.readLaterItem = readLater; OSKLinkBookmarkContentItem *linkBookmarking = [[OSKLinkBookmarkContentItem alloc] init]; @@ -188,16 +195,19 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; linkBookmarking.tags = @[appName]; linkBookmarking.markToRead = YES; + [linkBookmarking setBranchUrl]; content.linkBookmarkItem = linkBookmarking; OSKWebBrowserContentItem *browserItem = [[OSKWebBrowserContentItem alloc] init]; browserItem.url = URLforCanonicalURL; + [browserItem setBranchUrl]; content.webBrowserItem = browserItem; } OSKToDoListEntryContentItem *toDoList = [[OSKToDoListEntryContentItem alloc] init]; toDoList.title = [NSString stringWithFormat:@"Look into message from %@", authorName]; toDoList.notes = [NSString stringWithFormat:@"%@\n\n%@", text, canonicalURL]; + [toDoList setBranchUrl]; content.toDoListItem = toDoList; OSKPasswordManagementAppSearchContentItem *passwordSearchItem = [[OSKPasswordManagementAppSearchContentItem alloc] init]; @@ -222,6 +232,7 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * OSKTextEditingContentItem *textEditing = [[OSKTextEditingContentItem alloc] init]; textEditing.text = emailItem.body; + [textEditing setBranchUrl]; content.textEditingItem = textEditing; return content; diff --git a/Overshare Kit/OSKShareableContentItem.h b/Overshare Kit/OSKShareableContentItem.h index 5faa038..f59833c 100644 --- a/Overshare Kit/OSKShareableContentItem.h +++ b/Overshare Kit/OSKShareableContentItem.h @@ -7,6 +7,7 @@ // @import UIKit; +#import "Branch.h" extern NSString * const OSKShareableContentItemType_MicroblogPost; extern NSString * const OSKShareableContentItemType_Facebook; @@ -57,14 +58,23 @@ extern NSString * const OSKShareableContentItemType_TextEditing; */ @property (strong, nonatomic) UIImage *alternateActivityIcon; + +// --- Branch --- +@property(strong, nonatomic) NSMutableArray *allURLs; + /** Returns either one of the officially supported item types listed above, or a custom item type. @warning Required. Subclasses must override without calling super. */ + - (NSString *)itemType; +// --- Branch --- +// Processes all URLs in the content item with Branch getShortUrl +- (NSURL *)setBranchUrl; + /** Additional activity-specific or contextual info. diff --git a/Overshare Kit/OSKShareableContentItem.m b/Overshare Kit/OSKShareableContentItem.m index adb5c71..34bb6f3 100644 --- a/Overshare Kit/OSKShareableContentItem.m +++ b/Overshare Kit/OSKShareableContentItem.m @@ -23,6 +23,8 @@ NSString * const OSKShareableContentItemType_AirDrop = @"OSKShareableContentItemType_AirDrop"; NSString * const OSKShareableContentItemType_TextEditing = @"OSKShareableContentItemType_TextEditing"; +NSMutableArray *allURLs; + @implementation OSKShareableContentItem - (instancetype)init { @@ -38,6 +40,95 @@ - (NSString *)itemType { return nil; } +// --- Branch --- +// Branch URL Methods + +- (NSURL *)setBranchUrl { + NSURL *returnUrl; + if ([self.itemType isEqualToString:OSKShareableContentItemType_Facebook]) { + returnUrl = ((OSKFacebookContentItem*)self).link; + } else if ([@[ + OSKShareableContentItemType_ReadLater, + OSKShareableContentItemType_LinkBookmark] + containsObject:self.itemType]) { + returnUrl = ((OSKReadLaterContentItem*)self).url; + } else if ([@[ + OSKShareableContentItemType_MicroblogPost, + OSKShareableContentItemType_BlogPost, + OSKShareableContentItemType_CopyToPasteboard, + OSKShareableContentItemType_TextEditing + ] containsObject:self.itemType]) { + NSString *text = ((OSKBlogPostContentItem*)self).text; + [self identifyAllUrlsAndReplaceInString:text]; + returnUrl = [NSURL URLWithString:text]; + } else if ([@[ + OSKShareableContentItemType_Email, + OSKShareableContentItemType_SMS + ] containsObject:self.itemType]) { + NSString *body = ((OSKEmailContentItem*)self).body; + [self identifyAllUrlsAndReplaceInString:body]; + returnUrl = [NSURL URLWithString:body]; + } else if (self.itemType == OSKShareableContentItemType_ToDoListEntry) { + NSString *notes = ((OSKToDoListEntryContentItem*)self).notes; + [self identifyAllUrlsAndReplaceInString:notes]; + returnUrl = [NSURL URLWithString:notes]; + } + return returnUrl; +} + +// identifies all links in a string, and replaces them with Branch short links +- (void)identifyAllUrlsAndReplaceInString:(NSString *)string { + // Find all URLs in a string + NSDataDetector *detect = [[NSDataDetector alloc] initWithTypes:NSTextCheckingTypeLink error:nil]; + self.allURLs = [[detect matchesInString:string options:0 range:NSMakeRange(0, [string length])] mutableCopy]; + + // Replace each URL in the string with a Branch Short URL + for (int i=0; i<[self.allURLs count]; i++) { + NSTextCheckingResult *linkResult = self.allURLs[i]; + [self processURLForBranch:linkResult.URL]; + } +} + +- (void)processURLForBranch:(NSURL *)url { + // Sinleton Branch instance + Branch *branch = [Branch getInstance]; + + // Branch Link params + NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; + [params setObject:url forKey:@"$desktop_url"]; + [params setObject:url forKey:@"$ios_url"]; + [params setObject:url forKey:@"$android_url"]; + /* + [branch getShortURLWithParams:params andCallback:^(NSString *url, NSError *error) { + if(!error) { + // put the link somewhere + } + }]; + */ +} + +// come back to this, need to define multiple methods for any combination of arguments +- (void)shareableBranchWithUrl:(NSURL *)url + andParams:(NSDictionary *)params + andTags:(NSArray *)tags + andChannel:(NSString *)channel + andFeature:(NSString *)feature + andStage:(NSString *)stage + andAlias:(NSString *)alias + andCallback:(callbackWithUrl)callback { + NSLog(@"url: %@", url); + NSLog(@"params: %@", params); + NSLog(@"tags: %@", tags); + NSLog(@"channel: %@", channel); + NSLog(@"feature: %@", feature); + NSLog(@"stage: %@", stage); + NSLog(@"alias: %@", alias); + NSLog(@"callback: %@", callback); +} + +// End Branch Url Methods +// --- Branch --- + @end @implementation OSKMicroblogPostContentItem From 62267d84b0fe44831421b42bc3508d1d6ccd3754 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Wed, 21 Jan 2015 22:12:31 -0500 Subject: [PATCH 14/49] Make sure Branch link routing always runs --- .../Overshare/Overshare/OSKAppDelegate.m | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m index 40a5ee5..49052a5 100644 --- a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m +++ b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m @@ -110,6 +110,16 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl BOOL success = NO; + // Branch deep link handeler + // pass the url to the handle deep link call + // if handleDeepLink returns YES, and you registered a callback in initSessionAndRegisterDeepLinkHandler, the callback will be called with the data associated with the deep link. + if (![@"bnc_no_value" isEqualToString:[BNCPreferenceHelper getAppKey]] && + ![[Branch getInstance] handleDeepLink:url]) { + + // do other deep link routing for the Facebook SDK, Pinterest SDK, etc + } + + // OvershareKit deep link routing if ([[OSKADNLoginManager sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation]) { success = YES; } @@ -119,13 +129,6 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl else if ([GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation]) { success = YES; } - // Branch deep link handeler - // pass the url to the handle deep link call - // if handleDeepLink returns YES, and you registered a callback in initSessionAndRegisterDeepLinkHandler, the callback will be called with the data associated with the deep link - else if (![[Branch getInstance] handleDeepLink:url]) { - success = YES; - // do other deep link routing for the Facebook SDK, Pinterest SDK, etc - } else { // if you handle your own custom url-schemes, do it here // success = whatever; From f46e8fb37d7977212054987012e6d7770c250ade Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Thu, 22 Jan 2015 07:36:39 -0500 Subject: [PATCH 15/49] No need to check for key, getInstance does this --- .../Overshare/Overshare/OSKAppDelegate.m | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m index 49052a5..38b4c1d 100644 --- a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m +++ b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m @@ -16,7 +16,6 @@ // Include Branch, and Branch preference helper #import "Branch.h" -#import "BNCPreferenceHelper.h" @implementation OSKAppDelegate @@ -43,28 +42,25 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( For full documentation, see README.md in https://github.com/BranchMetrics/Branch-iOS-SDK */ - // Only initiate Branch if API key is defined in plist - if (![@"bnc_no_value" isEqualToString:[BNCPreferenceHelper getAppKey]]) { - // A Pointer to the signleton instance of Branch. The first time this is called in the app lifecycle, a Branch instance is synchronously instatiated. - Branch *branch = [Branch getInstance]; - + // A Pointer to the signleton instance of Branch. The first time this is called in the app lifecycle, a Branch instance is synchronously instatiated. + Branch *branch = [Branch getInstance]; + #ifdef DEBUG - // Verbose logs for debugging - [Branch setDebug]; + // Verbose logs for debugging + [Branch setDebug]; #endif - - // Initiates a Branch session, and registers a callback. If you created a custom link with your own custom dictionary data, you probably want to know when the user session init finishes, so you can check that data. Think of this callback as your "deep link router". If your app opens with some data, you want to route the user depending on the data you passed in. Otherwise, send them to a generic install flow. - [branch initSessionWithLaunchOptions:launchOptions isReferrable:YES andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) { - if (!error) { - NSLog(@"finished init with params = %@", [params description]); - - // example dictionary data - // NSString *name = [params objectForKey:@"user"]; - // NSString *profileUrl = [params objectForKey:@"profile_pic"]; - // NSString *description = [params objectForKey:@"description"]; - } - }]; - } + + // Initiates a Branch session, and registers a callback. If you created a custom link with your own custom dictionary data, you probably want to know when the user session init finishes, so you can check that data. Think of this callback as your "deep link router". If your app opens with some data, you want to route the user depending on the data you passed in. Otherwise, send them to a generic install flow. + [branch initSessionWithLaunchOptions:launchOptions isReferrable:YES andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) { + if (!error) { + NSLog(@"finished init with params = %@", [params description]); + + // example dictionary data + // NSString *name = [params objectForKey:@"user"]; + // NSString *profileUrl = [params objectForKey:@"profile_pic"]; + // NSString *description = [params objectForKey:@"description"]; + } + }]; UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [self setWindow:window]; @@ -113,8 +109,7 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl // Branch deep link handeler // pass the url to the handle deep link call // if handleDeepLink returns YES, and you registered a callback in initSessionAndRegisterDeepLinkHandler, the callback will be called with the data associated with the deep link. - if (![@"bnc_no_value" isEqualToString:[BNCPreferenceHelper getAppKey]] && - ![[Branch getInstance] handleDeepLink:url]) { + if (![[Branch getInstance] handleDeepLink:url]) { // do other deep link routing for the Facebook SDK, Pinterest SDK, etc } From a2d157336278dbb95709b6b65f0e26c533015c9f Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Thu, 22 Jan 2015 10:27:41 -0500 Subject: [PATCH 16/49] Returns branch URLs with defaults Pointer to self in block callback needs work --- Overshare Kit/OSKShareableContent.m | 18 +++---- Overshare Kit/OSKShareableContentItem.h | 18 ++++++- Overshare Kit/OSKShareableContentItem.m | 49 ++++++++++++------- .../Overshare/Overshare/OSKAppDelegate.m | 2 + .../Overshare/SampleTimelineViewController.m | 2 +- 5 files changed, 59 insertions(+), 30 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index cc54abc..b38c800 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -153,13 +153,13 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * OSKCopyToPasteboardContentItem *copyTextToPasteboard = [[OSKCopyToPasteboardContentItem alloc] init]; copyTextToPasteboard.text = text; copyTextToPasteboard.alternateActivityName = @"Copy Text"; - [copyTextToPasteboard setBranchUrl]; + //[copyTextToPasteboard setBranchUrl]; content.pasteboardItem = copyTextToPasteboard; OSKCopyToPasteboardContentItem *copyURLToPasteboard = [[OSKCopyToPasteboardContentItem alloc] init]; copyURLToPasteboard.text = canonicalURL; copyURLToPasteboard.alternateActivityName = @"Copy URL"; - [copyURLToPasteboard setBranchUrl]; + //[copyURLToPasteboard setBranchUrl]; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { copyURLToPasteboard.alternateActivityIcon = [UIImage imageNamed:@"osk-copyIcon-purple-76.png"]; } else { @@ -172,13 +172,13 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * emailItem.body = [NSString stringWithFormat:@"“%@”\n\n(Via @%@)\n\n%@ ", text, authorName, canonicalURL]; emailItem.subject = @"Clipper Ships Sail On the Ocean"; emailItem.attachments = images.copy; - [emailItem setBranchUrl]; + //[emailItem setBranchUrl]; content.emailItem = emailItem; OSKSMSContentItem *smsItem = [[OSKSMSContentItem alloc] init]; smsItem.body = microblogPost.text; smsItem.attachments = images; - [smsItem setBranchUrl]; + //[smsItem setBranchUrl]; content.smsItem = smsItem; if (URLforCanonicalURL) { @@ -186,7 +186,7 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * readLater.url = URLforCanonicalURL; readLater.title = [NSString stringWithFormat:@"Post by %@", authorName]; readLater.itemDescription = text; - [readLater setBranchUrl]; + //[readLater setBranchUrl]; content.readLaterItem = readLater; OSKLinkBookmarkContentItem *linkBookmarking = [[OSKLinkBookmarkContentItem alloc] init]; @@ -195,19 +195,19 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; linkBookmarking.tags = @[appName]; linkBookmarking.markToRead = YES; - [linkBookmarking setBranchUrl]; + //[linkBookmarking setBranchUrl]; content.linkBookmarkItem = linkBookmarking; OSKWebBrowserContentItem *browserItem = [[OSKWebBrowserContentItem alloc] init]; browserItem.url = URLforCanonicalURL; - [browserItem setBranchUrl]; + //[browserItem setBranchUrl]; content.webBrowserItem = browserItem; } OSKToDoListEntryContentItem *toDoList = [[OSKToDoListEntryContentItem alloc] init]; toDoList.title = [NSString stringWithFormat:@"Look into message from %@", authorName]; toDoList.notes = [NSString stringWithFormat:@"%@\n\n%@", text, canonicalURL]; - [toDoList setBranchUrl]; + //[toDoList setBranchUrl]; content.toDoListItem = toDoList; OSKPasswordManagementAppSearchContentItem *passwordSearchItem = [[OSKPasswordManagementAppSearchContentItem alloc] init]; @@ -232,7 +232,7 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * OSKTextEditingContentItem *textEditing = [[OSKTextEditingContentItem alloc] init]; textEditing.text = emailItem.body; - [textEditing setBranchUrl]; + //[textEditing setBranchUrl]; content.textEditingItem = textEditing; return content; diff --git a/Overshare Kit/OSKShareableContentItem.h b/Overshare Kit/OSKShareableContentItem.h index f59833c..af66ac6 100644 --- a/Overshare Kit/OSKShareableContentItem.h +++ b/Overshare Kit/OSKShareableContentItem.h @@ -60,8 +60,24 @@ extern NSString * const OSKShareableContentItemType_TextEditing; // --- Branch --- + +/** + A mutable array of all the URL Results found in any test, body, or notes NSString + */ @property(strong, nonatomic) NSMutableArray *allURLs; +/** + A mutable array of all the branch URLs of URLs found in any test, body, or notes NSString + */ +@property(strong, nonatomic) NSMutableArray *branchURLs; + +/** + The Branch URL of the original link or url + */ +@property (strong, nonatomic) NSURL *branchURL; + +// --- End Branch --- + /** Returns either one of the officially supported item types listed above, or a custom item type. @@ -73,7 +89,7 @@ extern NSString * const OSKShareableContentItemType_TextEditing; // --- Branch --- // Processes all URLs in the content item with Branch getShortUrl -- (NSURL *)setBranchUrl; +- (void)setBranchUrl; /** Additional activity-specific or contextual info. diff --git a/Overshare Kit/OSKShareableContentItem.m b/Overshare Kit/OSKShareableContentItem.m index 34bb6f3..cfa7c21 100644 --- a/Overshare Kit/OSKShareableContentItem.m +++ b/Overshare Kit/OSKShareableContentItem.m @@ -24,6 +24,8 @@ NSString * const OSKShareableContentItemType_TextEditing = @"OSKShareableContentItemType_TextEditing"; NSMutableArray *allURLs; +NSMutableArray *branchURLs; +NSURL *branchURL; @implementation OSKShareableContentItem @@ -31,6 +33,7 @@ - (instancetype)init { self = [super init]; if (self) { _userInfo = [[NSMutableDictionary alloc] init]; + _branchURLs = [[NSMutableArray alloc] init]; } return self; } @@ -43,15 +46,14 @@ - (NSString *)itemType { // --- Branch --- // Branch URL Methods -- (NSURL *)setBranchUrl { - NSURL *returnUrl; +- (void)setBranchUrl { if ([self.itemType isEqualToString:OSKShareableContentItemType_Facebook]) { - returnUrl = ((OSKFacebookContentItem*)self).link; + [self processURLForBranch:((OSKFacebookContentItem*)self).link withArrayIndex:nil]; } else if ([@[ OSKShareableContentItemType_ReadLater, OSKShareableContentItemType_LinkBookmark] containsObject:self.itemType]) { - returnUrl = ((OSKReadLaterContentItem*)self).url; + [self processURLForBranch:((OSKReadLaterContentItem*)self).url withArrayIndex:nil]; } else if ([@[ OSKShareableContentItemType_MicroblogPost, OSKShareableContentItemType_BlogPost, @@ -60,51 +62,61 @@ - (NSURL *)setBranchUrl { ] containsObject:self.itemType]) { NSString *text = ((OSKBlogPostContentItem*)self).text; [self identifyAllUrlsAndReplaceInString:text]; - returnUrl = [NSURL URLWithString:text]; } else if ([@[ OSKShareableContentItemType_Email, OSKShareableContentItemType_SMS ] containsObject:self.itemType]) { NSString *body = ((OSKEmailContentItem*)self).body; [self identifyAllUrlsAndReplaceInString:body]; - returnUrl = [NSURL URLWithString:body]; } else if (self.itemType == OSKShareableContentItemType_ToDoListEntry) { NSString *notes = ((OSKToDoListEntryContentItem*)self).notes; [self identifyAllUrlsAndReplaceInString:notes]; - returnUrl = [NSURL URLWithString:notes]; } - return returnUrl; } // identifies all links in a string, and replaces them with Branch short links - (void)identifyAllUrlsAndReplaceInString:(NSString *)string { // Find all URLs in a string + NSLog(@"String: %@", string); NSDataDetector *detect = [[NSDataDetector alloc] initWithTypes:NSTextCheckingTypeLink error:nil]; self.allURLs = [[detect matchesInString:string options:0 range:NSMakeRange(0, [string length])] mutableCopy]; + NSLog(@"Matches: %@", self.allURLs); // Replace each URL in the string with a Branch Short URL for (int i=0; i<[self.allURLs count]; i++) { NSTextCheckingResult *linkResult = self.allURLs[i]; - [self processURLForBranch:linkResult.URL]; + [self processURLForBranch:linkResult.URL withArrayIndex:(NSUInteger *)(unsigned long)i]; } } -- (void)processURLForBranch:(NSURL *)url { +- (void)processURLForBranch:(NSURL *)url withArrayIndex:(NSUInteger *)index { // Sinleton Branch instance Branch *branch = [Branch getInstance]; // Branch Link params NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; - [params setObject:url forKey:@"$desktop_url"]; - [params setObject:url forKey:@"$ios_url"]; - [params setObject:url forKey:@"$android_url"]; - /* - [branch getShortURLWithParams:params andCallback:^(NSString *url, NSError *error) { + [params setObject:[url absoluteString] forKey:@"$desktop_url"]; + [params setObject:[url absoluteString] forKey:@"$ios_url"]; + [params setObject:[url absoluteString] forKey:@"$android_url"]; + + __weak OSKShareableContentItem *weakSelf = self; + + [branch getShortURLWithParams:params andCallback:^(NSString *branchURL, NSError *error) { if(!error) { - // put the link somewhere + __strong OSKShareableContentItem *strongSelf = weakSelf; + if (index) { + [strongSelf.branchURLs addObject:[NSURL URLWithString:branchURL]]; + NSLog(@"URL Array: %@", strongSelf.branchURLs); + } else { + strongSelf.branchURL = [NSURL URLWithString:branchURL]; + NSLog(@"URL: %@", strongSelf.branchURL); + } } }]; - */ +} + +- (void)branchURLCallback { + } // come back to this, need to define multiple methods for any combination of arguments @@ -126,8 +138,7 @@ - (void)shareableBranchWithUrl:(NSURL *)url NSLog(@"callback: %@", callback); } -// End Branch Url Methods -// --- Branch --- +// --- End Branch --- @end diff --git a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m index 38b4c1d..4331ad8 100644 --- a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m +++ b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m @@ -106,6 +106,7 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl BOOL success = NO; + // --- Branch --- // Branch deep link handeler // pass the url to the handle deep link call // if handleDeepLink returns YES, and you registered a callback in initSessionAndRegisterDeepLinkHandler, the callback will be called with the data associated with the deep link. @@ -113,6 +114,7 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl // do other deep link routing for the Facebook SDK, Pinterest SDK, etc } + // --- End Branch --- // OvershareKit deep link routing if ([[OSKADNLoginManager sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation]) { diff --git a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m index 563b4e3..3549ded 100644 --- a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m +++ b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m @@ -70,7 +70,7 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { // 1) Create the shareable content from the user's source content. - NSString *text = @"Me and my dad make models of clipper ships. #Clipperships sail on the ocean."; + NSString *text = @"Me and my dad make models of clipper ships. #Clipperships sail on the ocean. http://www.google.com"; NSArray *images = @[[UIImage imageNamed:@"soda.jpg"], [UIImage imageNamed:@"rain.jpg"], [UIImage imageNamed:@"type.jpg"]]; From 1f1aa56059619a1fe2a093e4be03862c098bc596 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Thu, 22 Jan 2015 10:28:41 -0500 Subject: [PATCH 17/49] Remove junk method in OSKShareableContentItem --- Overshare Kit/OSKShareableContentItem.m | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Overshare Kit/OSKShareableContentItem.m b/Overshare Kit/OSKShareableContentItem.m index cfa7c21..f560e2a 100644 --- a/Overshare Kit/OSKShareableContentItem.m +++ b/Overshare Kit/OSKShareableContentItem.m @@ -115,10 +115,6 @@ - (void)processURLForBranch:(NSURL *)url withArrayIndex:(NSUInteger *)index { }]; } -- (void)branchURLCallback { - -} - // come back to this, need to define multiple methods for any combination of arguments - (void)shareableBranchWithUrl:(NSURL *)url andParams:(NSDictionary *)params From bc7bcfcc5d3cb99ad91504b9eee9121fd71eea4e Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Thu, 22 Jan 2015 15:40:23 -0500 Subject: [PATCH 18/49] Default branch links functional Functional for Facebook, Browser, Read later, and Bookmark --- Overshare Kit/OSKShareableContent.m | 128 ++++++++++++++++++++++-- Overshare Kit/OSKShareableContentItem.h | 25 ----- Overshare Kit/OSKShareableContentItem.m | 98 ------------------ 3 files changed, 117 insertions(+), 134 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index b38c800..38f1ac4 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -10,8 +10,96 @@ #import "OSKShareableContentItem.h" +#import "Branch.h" + @implementation OSKShareableContent +- (void)processURLForBranchWithURL:(NSURL *)url + andTags:(NSArray *)tags + andChannel:(NSString *)channel + andFeature:(NSString *)feature + andStage:(NSString *)stage + andAlias:(NSString *)alias { + + // Sinleton Branch instance + Branch *branch = [Branch getInstance]; + + // Branch Link params + NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; + + //probably remove + [params setObject:[url absoluteString] forKey:@"$desktop_url"]; + //certainly remove + [params setObject:[url absoluteString] forKey:@"$ios_url"]; + [params setObject:[url absoluteString] forKey:@"$android_url"]; + + // Weak block reference to self + __weak OSKShareableContent *weakContent = self; + + // Create Branch Short URL for each channel + if([channel isEqualToString:@"facebook"]) { + [branch getShortURLWithParams:params + andTags:tags + andChannel:channel + andFeature:feature + andStage:stage + andAlias:alias + andCallback:^(NSString *url, NSError *error) { + __strong OSKShareableContent *strongContent = weakContent; + strongContent.facebookItem.link = [NSURL URLWithString:url]; + }]; + } else if ([channel isEqualToString:@"browser"]) { + [branch getShortURLWithParams:params + andTags:tags + andChannel:channel + andFeature:feature + andStage:stage + andAlias:alias + andCallback:^(NSString *url, NSError *error) { + __strong OSKShareableContent *strongContent = weakContent; + strongContent.webBrowserItem.url = [NSURL URLWithString:url]; + }]; + } else if ([channel isEqualToString:@"read_later"]) { + [branch getShortURLWithParams:params + andTags:tags + andChannel:channel + andFeature:feature + andStage:stage + andAlias:alias + andCallback:^(NSString *url, NSError *error) { + __strong OSKShareableContent *strongContent = weakContent; + strongContent.readLaterItem.url = [NSURL URLWithString:url]; + }]; + } else if ([channel isEqualToString:@"bookmark"]) { + [branch getShortURLWithParams:params + andTags:tags + andChannel:channel + andFeature:feature + andStage:stage + andAlias:alias + andCallback:^(NSString *url, NSError *error) { + __strong OSKShareableContent *strongContent = weakContent; + strongContent.linkBookmarkItem.url = [NSURL URLWithString:url]; + }]; + } +} + +/* +// identifies all links in a string, and replaces them with Branch short links +- (void)identifyAllUrlsAndReplaceInString:(NSString *)string { + // Find all URLs in a string + NSLog(@"String: %@", string); + NSDataDetector *detect = [[NSDataDetector alloc] initWithTypes:NSTextCheckingTypeLink error:nil]; + self.allURLs = [[detect matchesInString:string options:0 range:NSMakeRange(0, [string length])] mutableCopy]; + NSLog(@"Matches: %@", self.allURLs); + + // Replace each URL in the string with a Branch Short URL + for (int i=0; i<[self.allURLs count]; i++) { + NSTextCheckingResult *linkResult = self.allURLs[i]; + [self processURLForBranch:linkResult.URL withArrayIndex:(NSUInteger *)(unsigned long)i]; + } +} +*/ + (instancetype)contentFromText:(NSString *)text { NSParameterAssert(text.length); @@ -141,25 +229,22 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * // Image posts cannot be link posts and vice versa. facebook.images = images; } - [facebook setBranchUrl]; content.facebookItem = facebook; OSKMicroblogPostContentItem *microblogPost = [[OSKMicroblogPostContentItem alloc] init]; microblogPost.text = [NSString stringWithFormat:@"“%@” (Via @%@) %@ ", text, authorName, canonicalURL]; microblogPost.images = images; - [microblogPost setBranchUrl]; + //[microblogPost setBranchUrl]; content.microblogPostItem = microblogPost; OSKCopyToPasteboardContentItem *copyTextToPasteboard = [[OSKCopyToPasteboardContentItem alloc] init]; copyTextToPasteboard.text = text; copyTextToPasteboard.alternateActivityName = @"Copy Text"; - //[copyTextToPasteboard setBranchUrl]; content.pasteboardItem = copyTextToPasteboard; OSKCopyToPasteboardContentItem *copyURLToPasteboard = [[OSKCopyToPasteboardContentItem alloc] init]; copyURLToPasteboard.text = canonicalURL; copyURLToPasteboard.alternateActivityName = @"Copy URL"; - //[copyURLToPasteboard setBranchUrl]; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { copyURLToPasteboard.alternateActivityIcon = [UIImage imageNamed:@"osk-copyIcon-purple-76.png"]; } else { @@ -172,13 +257,11 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * emailItem.body = [NSString stringWithFormat:@"“%@”\n\n(Via @%@)\n\n%@ ", text, authorName, canonicalURL]; emailItem.subject = @"Clipper Ships Sail On the Ocean"; emailItem.attachments = images.copy; - //[emailItem setBranchUrl]; content.emailItem = emailItem; OSKSMSContentItem *smsItem = [[OSKSMSContentItem alloc] init]; smsItem.body = microblogPost.text; smsItem.attachments = images; - //[smsItem setBranchUrl]; content.smsItem = smsItem; if (URLforCanonicalURL) { @@ -186,7 +269,6 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * readLater.url = URLforCanonicalURL; readLater.title = [NSString stringWithFormat:@"Post by %@", authorName]; readLater.itemDescription = text; - //[readLater setBranchUrl]; content.readLaterItem = readLater; OSKLinkBookmarkContentItem *linkBookmarking = [[OSKLinkBookmarkContentItem alloc] init]; @@ -195,19 +277,16 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; linkBookmarking.tags = @[appName]; linkBookmarking.markToRead = YES; - //[linkBookmarking setBranchUrl]; content.linkBookmarkItem = linkBookmarking; OSKWebBrowserContentItem *browserItem = [[OSKWebBrowserContentItem alloc] init]; browserItem.url = URLforCanonicalURL; - //[browserItem setBranchUrl]; content.webBrowserItem = browserItem; } OSKToDoListEntryContentItem *toDoList = [[OSKToDoListEntryContentItem alloc] init]; toDoList.title = [NSString stringWithFormat:@"Look into message from %@", authorName]; toDoList.notes = [NSString stringWithFormat:@"%@\n\n%@", text, canonicalURL]; - //[toDoList setBranchUrl]; content.toDoListItem = toDoList; OSKPasswordManagementAppSearchContentItem *passwordSearchItem = [[OSKPasswordManagementAppSearchContentItem alloc] init]; @@ -232,9 +311,36 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * OSKTextEditingContentItem *textEditing = [[OSKTextEditingContentItem alloc] init]; textEditing.text = emailItem.body; - //[textEditing setBranchUrl]; content.textEditingItem = textEditing; + // Call Branch URLs + if (URLforCanonicalURL) { + [content processURLForBranchWithURL:URLforCanonicalURL + andTags:nil + andChannel:@"facebook" + andFeature:nil + andStage:nil + andAlias:nil]; + [content processURLForBranchWithURL:URLforCanonicalURL + andTags:nil + andChannel:@"browser" + andFeature:nil + andStage:nil + andAlias:nil]; + [content processURLForBranchWithURL:URLforCanonicalURL + andTags:nil + andChannel:@"read_later" + andFeature:nil + andStage:nil + andAlias:nil]; + [content processURLForBranchWithURL:URLforCanonicalURL + andTags:nil + andChannel:@"bookmark" + andFeature:nil + andStage:nil + andAlias:nil]; + } + return content; } diff --git a/Overshare Kit/OSKShareableContentItem.h b/Overshare Kit/OSKShareableContentItem.h index af66ac6..8d4ea5e 100644 --- a/Overshare Kit/OSKShareableContentItem.h +++ b/Overshare Kit/OSKShareableContentItem.h @@ -7,7 +7,6 @@ // @import UIKit; -#import "Branch.h" extern NSString * const OSKShareableContentItemType_MicroblogPost; extern NSString * const OSKShareableContentItemType_Facebook; @@ -58,26 +57,6 @@ extern NSString * const OSKShareableContentItemType_TextEditing; */ @property (strong, nonatomic) UIImage *alternateActivityIcon; - -// --- Branch --- - -/** - A mutable array of all the URL Results found in any test, body, or notes NSString - */ -@property(strong, nonatomic) NSMutableArray *allURLs; - -/** - A mutable array of all the branch URLs of URLs found in any test, body, or notes NSString - */ -@property(strong, nonatomic) NSMutableArray *branchURLs; - -/** - The Branch URL of the original link or url - */ -@property (strong, nonatomic) NSURL *branchURL; - -// --- End Branch --- - /** Returns either one of the officially supported item types listed above, or a custom item type. @@ -87,10 +66,6 @@ extern NSString * const OSKShareableContentItemType_TextEditing; - (NSString *)itemType; -// --- Branch --- -// Processes all URLs in the content item with Branch getShortUrl -- (void)setBranchUrl; - /** Additional activity-specific or contextual info. diff --git a/Overshare Kit/OSKShareableContentItem.m b/Overshare Kit/OSKShareableContentItem.m index f560e2a..adb5c71 100644 --- a/Overshare Kit/OSKShareableContentItem.m +++ b/Overshare Kit/OSKShareableContentItem.m @@ -23,17 +23,12 @@ NSString * const OSKShareableContentItemType_AirDrop = @"OSKShareableContentItemType_AirDrop"; NSString * const OSKShareableContentItemType_TextEditing = @"OSKShareableContentItemType_TextEditing"; -NSMutableArray *allURLs; -NSMutableArray *branchURLs; -NSURL *branchURL; - @implementation OSKShareableContentItem - (instancetype)init { self = [super init]; if (self) { _userInfo = [[NSMutableDictionary alloc] init]; - _branchURLs = [[NSMutableArray alloc] init]; } return self; } @@ -43,99 +38,6 @@ - (NSString *)itemType { return nil; } -// --- Branch --- -// Branch URL Methods - -- (void)setBranchUrl { - if ([self.itemType isEqualToString:OSKShareableContentItemType_Facebook]) { - [self processURLForBranch:((OSKFacebookContentItem*)self).link withArrayIndex:nil]; - } else if ([@[ - OSKShareableContentItemType_ReadLater, - OSKShareableContentItemType_LinkBookmark] - containsObject:self.itemType]) { - [self processURLForBranch:((OSKReadLaterContentItem*)self).url withArrayIndex:nil]; - } else if ([@[ - OSKShareableContentItemType_MicroblogPost, - OSKShareableContentItemType_BlogPost, - OSKShareableContentItemType_CopyToPasteboard, - OSKShareableContentItemType_TextEditing - ] containsObject:self.itemType]) { - NSString *text = ((OSKBlogPostContentItem*)self).text; - [self identifyAllUrlsAndReplaceInString:text]; - } else if ([@[ - OSKShareableContentItemType_Email, - OSKShareableContentItemType_SMS - ] containsObject:self.itemType]) { - NSString *body = ((OSKEmailContentItem*)self).body; - [self identifyAllUrlsAndReplaceInString:body]; - } else if (self.itemType == OSKShareableContentItemType_ToDoListEntry) { - NSString *notes = ((OSKToDoListEntryContentItem*)self).notes; - [self identifyAllUrlsAndReplaceInString:notes]; - } -} - -// identifies all links in a string, and replaces them with Branch short links -- (void)identifyAllUrlsAndReplaceInString:(NSString *)string { - // Find all URLs in a string - NSLog(@"String: %@", string); - NSDataDetector *detect = [[NSDataDetector alloc] initWithTypes:NSTextCheckingTypeLink error:nil]; - self.allURLs = [[detect matchesInString:string options:0 range:NSMakeRange(0, [string length])] mutableCopy]; - NSLog(@"Matches: %@", self.allURLs); - - // Replace each URL in the string with a Branch Short URL - for (int i=0; i<[self.allURLs count]; i++) { - NSTextCheckingResult *linkResult = self.allURLs[i]; - [self processURLForBranch:linkResult.URL withArrayIndex:(NSUInteger *)(unsigned long)i]; - } -} - -- (void)processURLForBranch:(NSURL *)url withArrayIndex:(NSUInteger *)index { - // Sinleton Branch instance - Branch *branch = [Branch getInstance]; - - // Branch Link params - NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; - [params setObject:[url absoluteString] forKey:@"$desktop_url"]; - [params setObject:[url absoluteString] forKey:@"$ios_url"]; - [params setObject:[url absoluteString] forKey:@"$android_url"]; - - __weak OSKShareableContentItem *weakSelf = self; - - [branch getShortURLWithParams:params andCallback:^(NSString *branchURL, NSError *error) { - if(!error) { - __strong OSKShareableContentItem *strongSelf = weakSelf; - if (index) { - [strongSelf.branchURLs addObject:[NSURL URLWithString:branchURL]]; - NSLog(@"URL Array: %@", strongSelf.branchURLs); - } else { - strongSelf.branchURL = [NSURL URLWithString:branchURL]; - NSLog(@"URL: %@", strongSelf.branchURL); - } - } - }]; -} - -// come back to this, need to define multiple methods for any combination of arguments -- (void)shareableBranchWithUrl:(NSURL *)url - andParams:(NSDictionary *)params - andTags:(NSArray *)tags - andChannel:(NSString *)channel - andFeature:(NSString *)feature - andStage:(NSString *)stage - andAlias:(NSString *)alias - andCallback:(callbackWithUrl)callback { - NSLog(@"url: %@", url); - NSLog(@"params: %@", params); - NSLog(@"tags: %@", tags); - NSLog(@"channel: %@", channel); - NSLog(@"feature: %@", feature); - NSLog(@"stage: %@", stage); - NSLog(@"alias: %@", alias); - NSLog(@"callback: %@", callback); -} - -// --- End Branch --- - @end @implementation OSKMicroblogPostContentItem From 524dc94d9fbbf9b42a0fd6e28eae9c722412df03 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Thu, 22 Jan 2015 21:19:01 -0500 Subject: [PATCH 19/49] Refactors default branch links to fix callback bug --- Overshare Kit/OSKShareableContent.h | 20 ++ Overshare Kit/OSKShareableContent.m | 182 +++++++++++++----- .../Overshare/Overshare/OSKAppDelegate.m | 2 +- .../Overshare/SampleTimelineViewController.m | 2 +- 4 files changed, 154 insertions(+), 52 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.h b/Overshare Kit/OSKShareableContent.h index 916d1c7..8df3218 100644 --- a/Overshare Kit/OSKShareableContent.h +++ b/Overshare Kit/OSKShareableContent.h @@ -137,6 +137,24 @@ These can be custom items, or additional instances of the official items above. */ @property (copy, nonatomic) NSString *title; + +// --- Branch --- + +@property (strong, nonatomic) NSMutableArray *channelsToProcessToBranch; + +@property (strong, nonatomic) NSMutableArray *channelsWithStringsToProcessToBranch; + +@property (strong, nonatomic) NSString *urlToProcessToBranch; + +@property (strong, nonatomic) NSArray *branchTags; + +@property (strong, nonatomic) NSString *branchFeature; + +@property (strong, nonatomic) NSString *branchStage; + +@property (strong, nonatomic) NSString *branchAlias; + +// --- End Branch --- @end /// ----------------------------------------- @@ -169,6 +187,8 @@ These can be custom items, or additional instances of the official items above. + (instancetype)contentFromImages:(NSArray *)images caption:(NSString *)caption; +- (void)processURLsForBranch; + @end diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index 38f1ac4..b85c868 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -14,30 +14,98 @@ @implementation OSKShareableContent -- (void)processURLForBranchWithURL:(NSURL *)url - andTags:(NSArray *)tags - andChannel:(NSString *)channel - andFeature:(NSString *)feature - andStage:(NSString *)stage - andAlias:(NSString *)alias { +// --- Branch --- + +- (void)processURLsForBranch { + + // Sinleton Branch instance + Branch *branch = [Branch getInstance]; + + // Branch Link params + NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; + + //probably remove + [params setObject:self.urlToProcessToBranch forKey:@"$desktop_url"]; + //certainly remove + [params setObject:self.urlToProcessToBranch forKey:@"$ios_url"]; + [params setObject:self.urlToProcessToBranch forKey:@"$android_url"]; + + // Weak block reference to self + __weak OSKShareableContent *weakContent = self; + + NSString *channel = [self.channelsToProcessToBranch firstObject]; + + // Content items that take a single URL as an argument + // Create Branch Short URL for each channel + [branch getShortURLWithParams:params + andTags:self.branchTags + andChannel:channel + andFeature:self.branchFeature + andStage:self.branchStage + andAlias:self.branchAlias + andCallback:^(NSString *url, NSError *error) { + __strong OSKShareableContent *strongContent = weakContent; + + NSString *channel = [self.channelsToProcessToBranch firstObject]; + + if([channel isEqualToString:@"facebook"]) { + strongContent.facebookItem.link = [NSURL URLWithString:url]; + NSLog(@"Facebook: %@", strongContent.facebookItem.link); + } else if ([channel isEqualToString:@"browser"]) { + strongContent.webBrowserItem.url = [NSURL URLWithString:url]; + NSLog(@"Browser: %@", strongContent.webBrowserItem.url); + } else if ([channel isEqualToString:@"read_later"]) { + strongContent.readLaterItem.url = [NSURL URLWithString:url]; + NSLog(@"Read Later: %@", strongContent.readLaterItem.url); + } else if ([channel isEqualToString:@"bookmark"]) { + strongContent.linkBookmarkItem.url = [NSURL URLWithString:url]; + NSLog(@"Bookmark: %@", strongContent.linkBookmarkItem.url); + } else if ([channel isEqualToString:@"microblog_twitter"]) { + //strongContent.linkBookmarkItem.url = [NSURL URLWithString:url]; + //NSLog(@"Twitter / Microblog: %@", strongContent.linkBookmarkItem.url); + } + + // Next channel + [self.channelsToProcessToBranch removeObjectAtIndex:0]; + if (self.channelsToProcessToBranch.count > 0) { + [self processURLsForBranch]; + } + }]; +} + +- (void)processURLForBranchWithString:(NSString *)stringWithURL + andTags:(NSArray *)tags + andChannel:(NSString *)channel + andFeature:(NSString *)feature + andStage:(NSString *)stage + andAlias:(NSString *)alias { // Sinleton Branch instance Branch *branch = [Branch getInstance]; + NSTextCheckingResult *urlCheckingResult = [self identifyAllUrlsAndReplaceInString:stringWithURL]; + + //get the URL from the end of the string + NSString *url = urlCheckingResult.URL.absoluteString; + + //remove the original URL from the end of the string + NSString *truncatedString = [stringWithURL stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; + // Branch Link params NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; //probably remove - [params setObject:[url absoluteString] forKey:@"$desktop_url"]; + [params setObject:url forKey:@"$desktop_url"]; //certainly remove - [params setObject:[url absoluteString] forKey:@"$ios_url"]; - [params setObject:[url absoluteString] forKey:@"$android_url"]; + [params setObject:url forKey:@"$ios_url"]; + [params setObject:url forKey:@"$android_url"]; // Weak block reference to self __weak OSKShareableContent *weakContent = self; + // Content items that put the URL in an NSString // Create Branch Short URL for each channel - if([channel isEqualToString:@"facebook"]) { + if([channel isEqualToString:@"microblog_twitter"]) { [branch getShortURLWithParams:params andTags:tags andChannel:channel @@ -46,9 +114,9 @@ - (void)processURLForBranchWithURL:(NSURL *)url andAlias:alias andCallback:^(NSString *url, NSError *error) { __strong OSKShareableContent *strongContent = weakContent; - strongContent.facebookItem.link = [NSURL URLWithString:url]; + strongContent.microblogPostItem.text = [truncatedString stringByAppendingString:url]; }]; - } else if ([channel isEqualToString:@"browser"]) { + } else if([channel isEqualToString:@"email"]) { [branch getShortURLWithParams:params andTags:tags andChannel:channel @@ -57,9 +125,9 @@ - (void)processURLForBranchWithURL:(NSURL *)url andAlias:alias andCallback:^(NSString *url, NSError *error) { __strong OSKShareableContent *strongContent = weakContent; - strongContent.webBrowserItem.url = [NSURL URLWithString:url]; + strongContent.emailItem.body = [truncatedString stringByAppendingString:url]; }]; - } else if ([channel isEqualToString:@"read_later"]) { + } else if([channel isEqualToString:@"sms"]) { [branch getShortURLWithParams:params andTags:tags andChannel:channel @@ -68,9 +136,9 @@ - (void)processURLForBranchWithURL:(NSURL *)url andAlias:alias andCallback:^(NSString *url, NSError *error) { __strong OSKShareableContent *strongContent = weakContent; - strongContent.readLaterItem.url = [NSURL URLWithString:url]; + strongContent.smsItem.body = [truncatedString stringByAppendingString:url]; }]; - } else if ([channel isEqualToString:@"bookmark"]) { + } else if([channel isEqualToString:@"todo"]) { [branch getShortURLWithParams:params andTags:tags andChannel:channel @@ -79,27 +147,36 @@ - (void)processURLForBranchWithURL:(NSURL *)url andAlias:alias andCallback:^(NSString *url, NSError *error) { __strong OSKShareableContent *strongContent = weakContent; - strongContent.linkBookmarkItem.url = [NSURL URLWithString:url]; + strongContent.toDoListItem.notes = [truncatedString stringByAppendingString:url]; + }]; + } else if([channel isEqualToString:@"text_editor"]) { + [branch getShortURLWithParams:params + andTags:tags + andChannel:channel + andFeature:feature + andStage:stage + andAlias:alias + andCallback:^(NSString *url, NSError *error) { + __strong OSKShareableContent *strongContent = weakContent; + strongContent.textEditingItem.text = [truncatedString stringByAppendingString:url]; }]; } + } -/* -// identifies all links in a string, and replaces them with Branch short links -- (void)identifyAllUrlsAndReplaceInString:(NSString *)string { + +// identifies all links in a string +- (NSTextCheckingResult *)identifyAllUrlsAndReplaceInString:(NSString *)string { // Find all URLs in a string - NSLog(@"String: %@", string); NSDataDetector *detect = [[NSDataDetector alloc] initWithTypes:NSTextCheckingTypeLink error:nil]; - self.allURLs = [[detect matchesInString:string options:0 range:NSMakeRange(0, [string length])] mutableCopy]; - NSLog(@"Matches: %@", self.allURLs); + NSMutableArray *allURLs = [[detect matchesInString:string options:0 range:NSMakeRange(0, [string length])] mutableCopy]; - // Replace each URL in the string with a Branch Short URL - for (int i=0; i<[self.allURLs count]; i++) { - NSTextCheckingResult *linkResult = self.allURLs[i]; - [self processURLForBranch:linkResult.URL withArrayIndex:(NSUInteger *)(unsigned long)i]; - } + //return the URL checking result at the end of the string + return [allURLs lastObject]; } -*/ + +// --- Branch --- + + (instancetype)contentFromText:(NSString *)text { NSParameterAssert(text.length); @@ -234,7 +311,6 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * OSKMicroblogPostContentItem *microblogPost = [[OSKMicroblogPostContentItem alloc] init]; microblogPost.text = [NSString stringWithFormat:@"“%@” (Via @%@) %@ ", text, authorName, canonicalURL]; microblogPost.images = images; - //[microblogPost setBranchUrl]; content.microblogPostItem = microblogPost; OSKCopyToPasteboardContentItem *copyTextToPasteboard = [[OSKCopyToPasteboardContentItem alloc] init]; @@ -315,30 +391,36 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * // Call Branch URLs if (URLforCanonicalURL) { - [content processURLForBranchWithURL:URLforCanonicalURL - andTags:nil - andChannel:@"facebook" - andFeature:nil - andStage:nil - andAlias:nil]; - [content processURLForBranchWithURL:URLforCanonicalURL - andTags:nil - andChannel:@"browser" - andFeature:nil - andStage:nil - andAlias:nil]; - [content processURLForBranchWithURL:URLforCanonicalURL - andTags:nil - andChannel:@"read_later" - andFeature:nil - andStage:nil - andAlias:nil]; - [content processURLForBranchWithURL:URLforCanonicalURL + + // Arrays of all channels + // Channels that have a url or link attribute + content.channelsToProcessToBranch = [@[ + @"facebook", + @"browser", + @"read_later", + @"bookmark", + @"microblog_twitter", + @"email", + @"sms", + @"todo", + @"text_editor" + ] mutableCopy]; + + // URL to process for each channel + content.urlToProcessToBranch = [URLforCanonicalURL absoluteString]; + + //Content iterms that have a url or link attribute + [content processURLsForBranch]; + + /* + //content items that put the URL in an NSString + [content processURLForBranchWithString:content.microblogPostItem.text andTags:nil - andChannel:@"bookmark" + andChannel:@"microblog_twitter" andFeature:nil andStage:nil andAlias:nil]; + */ } return content; diff --git a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m index 4331ad8..c9a47ab 100644 --- a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m +++ b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m @@ -47,7 +47,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( #ifdef DEBUG // Verbose logs for debugging - [Branch setDebug]; + //[Branch setDebug]; #endif // Initiates a Branch session, and registers a callback. If you created a custom link with your own custom dictionary data, you probably want to know when the user session init finishes, so you can check that data. Think of this callback as your "deep link router". If your app opens with some data, you want to route the user depending on the data you passed in. Otherwise, send them to a generic install flow. diff --git a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m index 3549ded..563b4e3 100644 --- a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m +++ b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m @@ -70,7 +70,7 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { // 1) Create the shareable content from the user's source content. - NSString *text = @"Me and my dad make models of clipper ships. #Clipperships sail on the ocean. http://www.google.com"; + NSString *text = @"Me and my dad make models of clipper ships. #Clipperships sail on the ocean."; NSArray *images = @[[UIImage imageNamed:@"soda.jpg"], [UIImage imageNamed:@"rain.jpg"], [UIImage imageNamed:@"type.jpg"]]; From 11312cbbd421614f7d2bccdae2716d3a15b7870c Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Thu, 22 Jan 2015 21:55:00 -0500 Subject: [PATCH 20/49] Sets up updating URLs within twitter, etc strings --- Overshare Kit/OSKShareableContent.m | 168 +++++++++++----------------- 1 file changed, 64 insertions(+), 104 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index b85c868..c88bd9e 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -61,8 +61,70 @@ - (void)processURLsForBranch { strongContent.linkBookmarkItem.url = [NSURL URLWithString:url]; NSLog(@"Bookmark: %@", strongContent.linkBookmarkItem.url); } else if ([channel isEqualToString:@"microblog_twitter"]) { - //strongContent.linkBookmarkItem.url = [NSURL URLWithString:url]; - //NSLog(@"Twitter / Microblog: %@", strongContent.linkBookmarkItem.url); + NSTextCheckingResult *urlCheckingResult = + [self identifyAllUrlsAndReplaceInString:strongContent.microblogPostItem.text]; + + //get the URL from the end of the string + NSString *url = urlCheckingResult.URL.absoluteString; + + //remove the original URL from the end of the string + NSString *truncatedString = [strongContent.microblogPostItem.text stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; + + strongContent.microblogPostItem.text = [truncatedString stringByAppendingString:url]; + + NSLog(@"Twitter / Microblog: %@", strongContent.microblogPostItem.text); + } else if ([channel isEqualToString:@"email"]) { + NSTextCheckingResult *urlCheckingResult = + [self identifyAllUrlsAndReplaceInString:strongContent.emailItem.body]; + + //get the URL from the end of the string + NSString *url = urlCheckingResult.URL.absoluteString; + + //remove the original URL from the end of the string + NSString *truncatedString = [strongContent.emailItem.body stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; + + strongContent.emailItem.body = [truncatedString stringByAppendingString:url]; + + NSLog(@"Email: %@", strongContent.emailItem.body); + } else if ([channel isEqualToString:@"sms"]) { + NSTextCheckingResult *urlCheckingResult = + [self identifyAllUrlsAndReplaceInString:strongContent.smsItem.body]; + + //get the URL from the end of the string + NSString *url = urlCheckingResult.URL.absoluteString; + + //remove the original URL from the end of the string + NSString *truncatedString = [strongContent.smsItem.body stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; + + strongContent.smsItem.body = [truncatedString stringByAppendingString:url]; + + NSLog(@"SMS: %@", strongContent.smsItem.body); + } else if ([channel isEqualToString:@"todo"]) { + NSTextCheckingResult *urlCheckingResult = + [self identifyAllUrlsAndReplaceInString:strongContent.toDoListItem.notes]; + + //get the URL from the end of the string + NSString *url = urlCheckingResult.URL.absoluteString; + + //remove the original URL from the end of the string + NSString *truncatedString = [strongContent.toDoListItem.notes stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; + + strongContent.toDoListItem.notes = [truncatedString stringByAppendingString:url]; + + NSLog(@"Todo: %@", strongContent.toDoListItem.notes); + } else if ([channel isEqualToString:@"text_editor"]) { + NSTextCheckingResult *urlCheckingResult = + [self identifyAllUrlsAndReplaceInString:strongContent.textEditingItem.text]; + + //get the URL from the end of the string + NSString *url = urlCheckingResult.URL.absoluteString; + + //remove the original URL from the end of the string + NSString *truncatedString = [strongContent.textEditingItem.text stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; + + strongContent.textEditingItem.text = [truncatedString stringByAppendingString:url]; + + NSLog(@"Text editor: %@", strongContent.textEditingItem.text); } // Next channel @@ -73,98 +135,6 @@ - (void)processURLsForBranch { }]; } -- (void)processURLForBranchWithString:(NSString *)stringWithURL - andTags:(NSArray *)tags - andChannel:(NSString *)channel - andFeature:(NSString *)feature - andStage:(NSString *)stage - andAlias:(NSString *)alias { - - // Sinleton Branch instance - Branch *branch = [Branch getInstance]; - - NSTextCheckingResult *urlCheckingResult = [self identifyAllUrlsAndReplaceInString:stringWithURL]; - - //get the URL from the end of the string - NSString *url = urlCheckingResult.URL.absoluteString; - - //remove the original URL from the end of the string - NSString *truncatedString = [stringWithURL stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; - - // Branch Link params - NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; - - //probably remove - [params setObject:url forKey:@"$desktop_url"]; - //certainly remove - [params setObject:url forKey:@"$ios_url"]; - [params setObject:url forKey:@"$android_url"]; - - // Weak block reference to self - __weak OSKShareableContent *weakContent = self; - - // Content items that put the URL in an NSString - // Create Branch Short URL for each channel - if([channel isEqualToString:@"microblog_twitter"]) { - [branch getShortURLWithParams:params - andTags:tags - andChannel:channel - andFeature:feature - andStage:stage - andAlias:alias - andCallback:^(NSString *url, NSError *error) { - __strong OSKShareableContent *strongContent = weakContent; - strongContent.microblogPostItem.text = [truncatedString stringByAppendingString:url]; - }]; - } else if([channel isEqualToString:@"email"]) { - [branch getShortURLWithParams:params - andTags:tags - andChannel:channel - andFeature:feature - andStage:stage - andAlias:alias - andCallback:^(NSString *url, NSError *error) { - __strong OSKShareableContent *strongContent = weakContent; - strongContent.emailItem.body = [truncatedString stringByAppendingString:url]; - }]; - } else if([channel isEqualToString:@"sms"]) { - [branch getShortURLWithParams:params - andTags:tags - andChannel:channel - andFeature:feature - andStage:stage - andAlias:alias - andCallback:^(NSString *url, NSError *error) { - __strong OSKShareableContent *strongContent = weakContent; - strongContent.smsItem.body = [truncatedString stringByAppendingString:url]; - }]; - } else if([channel isEqualToString:@"todo"]) { - [branch getShortURLWithParams:params - andTags:tags - andChannel:channel - andFeature:feature - andStage:stage - andAlias:alias - andCallback:^(NSString *url, NSError *error) { - __strong OSKShareableContent *strongContent = weakContent; - strongContent.toDoListItem.notes = [truncatedString stringByAppendingString:url]; - }]; - } else if([channel isEqualToString:@"text_editor"]) { - [branch getShortURLWithParams:params - andTags:tags - andChannel:channel - andFeature:feature - andStage:stage - andAlias:alias - andCallback:^(NSString *url, NSError *error) { - __strong OSKShareableContent *strongContent = weakContent; - strongContent.textEditingItem.text = [truncatedString stringByAppendingString:url]; - }]; - } - -} - - // identifies all links in a string - (NSTextCheckingResult *)identifyAllUrlsAndReplaceInString:(NSString *)string { // Find all URLs in a string @@ -411,16 +381,6 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * //Content iterms that have a url or link attribute [content processURLsForBranch]; - - /* - //content items that put the URL in an NSString - [content processURLForBranchWithString:content.microblogPostItem.text - andTags:nil - andChannel:@"microblog_twitter" - andFeature:nil - andStage:nil - andAlias:nil]; - */ } return content; From 12a2141e924bf968f6c68cc82f3201cbfa5f9997 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 10:18:07 -0500 Subject: [PATCH 21/49] URLs in microblog and text form work --- Overshare Kit/OSKShareableContent.m | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index c88bd9e..5af0939 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -64,9 +64,6 @@ - (void)processURLsForBranch { NSTextCheckingResult *urlCheckingResult = [self identifyAllUrlsAndReplaceInString:strongContent.microblogPostItem.text]; - //get the URL from the end of the string - NSString *url = urlCheckingResult.URL.absoluteString; - //remove the original URL from the end of the string NSString *truncatedString = [strongContent.microblogPostItem.text stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; @@ -77,9 +74,6 @@ - (void)processURLsForBranch { NSTextCheckingResult *urlCheckingResult = [self identifyAllUrlsAndReplaceInString:strongContent.emailItem.body]; - //get the URL from the end of the string - NSString *url = urlCheckingResult.URL.absoluteString; - //remove the original URL from the end of the string NSString *truncatedString = [strongContent.emailItem.body stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; @@ -90,9 +84,6 @@ - (void)processURLsForBranch { NSTextCheckingResult *urlCheckingResult = [self identifyAllUrlsAndReplaceInString:strongContent.smsItem.body]; - //get the URL from the end of the string - NSString *url = urlCheckingResult.URL.absoluteString; - //remove the original URL from the end of the string NSString *truncatedString = [strongContent.smsItem.body stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; @@ -103,9 +94,6 @@ - (void)processURLsForBranch { NSTextCheckingResult *urlCheckingResult = [self identifyAllUrlsAndReplaceInString:strongContent.toDoListItem.notes]; - //get the URL from the end of the string - NSString *url = urlCheckingResult.URL.absoluteString; - //remove the original URL from the end of the string NSString *truncatedString = [strongContent.toDoListItem.notes stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; @@ -116,9 +104,6 @@ - (void)processURLsForBranch { NSTextCheckingResult *urlCheckingResult = [self identifyAllUrlsAndReplaceInString:strongContent.textEditingItem.text]; - //get the URL from the end of the string - NSString *url = urlCheckingResult.URL.absoluteString; - //remove the original URL from the end of the string NSString *truncatedString = [strongContent.textEditingItem.text stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; From 1796df4fa25279d9b0bb94455588f54bfdc9cc83 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 10:30:11 -0500 Subject: [PATCH 22/49] Stubs out processing strings for URLs --- Overshare Kit/OSKShareableContent.m | 60 ++++++------------- .../Overshare/Overshare/OSKAppDelegate.m | 2 +- 2 files changed, 20 insertions(+), 42 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index 5af0939..2ebe320 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -61,65 +61,43 @@ - (void)processURLsForBranch { strongContent.linkBookmarkItem.url = [NSURL URLWithString:url]; NSLog(@"Bookmark: %@", strongContent.linkBookmarkItem.url); } else if ([channel isEqualToString:@"microblog_twitter"]) { - NSTextCheckingResult *urlCheckingResult = - [self identifyAllUrlsAndReplaceInString:strongContent.microblogPostItem.text]; - - //remove the original URL from the end of the string - NSString *truncatedString = [strongContent.microblogPostItem.text stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; - - strongContent.microblogPostItem.text = [truncatedString stringByAppendingString:url]; - + strongContent.microblogPostItem.text = [self branchifiedStringWithURL:url andOriginalString:strongContent.microblogPostItem.text]; NSLog(@"Twitter / Microblog: %@", strongContent.microblogPostItem.text); } else if ([channel isEqualToString:@"email"]) { - NSTextCheckingResult *urlCheckingResult = - [self identifyAllUrlsAndReplaceInString:strongContent.emailItem.body]; - - //remove the original URL from the end of the string - NSString *truncatedString = [strongContent.emailItem.body stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; - - strongContent.emailItem.body = [truncatedString stringByAppendingString:url]; - + strongContent.emailItem.body = [self branchifiedStringWithURL:url andOriginalString:strongContent.emailItem.body]; NSLog(@"Email: %@", strongContent.emailItem.body); } else if ([channel isEqualToString:@"sms"]) { - NSTextCheckingResult *urlCheckingResult = - [self identifyAllUrlsAndReplaceInString:strongContent.smsItem.body]; - - //remove the original URL from the end of the string - NSString *truncatedString = [strongContent.smsItem.body stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; - - strongContent.smsItem.body = [truncatedString stringByAppendingString:url]; - + strongContent.smsItem.body = [self branchifiedStringWithURL:url andOriginalString:strongContent.smsItem.body]; NSLog(@"SMS: %@", strongContent.smsItem.body); } else if ([channel isEqualToString:@"todo"]) { - NSTextCheckingResult *urlCheckingResult = - [self identifyAllUrlsAndReplaceInString:strongContent.toDoListItem.notes]; - - //remove the original URL from the end of the string - NSString *truncatedString = [strongContent.toDoListItem.notes stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; - - strongContent.toDoListItem.notes = [truncatedString stringByAppendingString:url]; - + strongContent.toDoListItem.notes = [ self branchifiedStringWithURL:url andOriginalString:strongContent.toDoListItem.notes]; NSLog(@"Todo: %@", strongContent.toDoListItem.notes); } else if ([channel isEqualToString:@"text_editor"]) { - NSTextCheckingResult *urlCheckingResult = - [self identifyAllUrlsAndReplaceInString:strongContent.textEditingItem.text]; - - //remove the original URL from the end of the string - NSString *truncatedString = [strongContent.textEditingItem.text stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; - - strongContent.textEditingItem.text = [truncatedString stringByAppendingString:url]; - + strongContent.textEditingItem.text = [self branchifiedStringWithURL:url andOriginalString:strongContent.textEditingItem.text]; NSLog(@"Text editor: %@", strongContent.textEditingItem.text); } // Next channel [self.channelsToProcessToBranch removeObjectAtIndex:0]; if (self.channelsToProcessToBranch.count > 0) { + NSLog(@"\n--------------------------------------\n"); [self processURLsForBranch]; } }]; } +// Processes strings of content, and replaces the URL at the end with the Branch URL provided +- (NSString *)branchifiedStringWithURL:(NSString *)branchURL andOriginalString:(NSString *)string { + // Identifies all links in a string + NSTextCheckingResult *urlCheckingResult = [self identifyAllUrlsAndReplaceInString:string]; + + // Remove the original URL from the end of the string + NSString *truncatedString = [string stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; + + // Append the original string with the Branch URL and return + return [truncatedString stringByAppendingString:branchURL]; +} + // identifies all links in a string - (NSTextCheckingResult *)identifyAllUrlsAndReplaceInString:(NSString *)string { // Find all URLs in a string @@ -130,7 +108,7 @@ - (NSTextCheckingResult *)identifyAllUrlsAndReplaceInString:(NSString *)string { return [allURLs lastObject]; } -// --- Branch --- +// --- End Branch --- + (instancetype)contentFromText:(NSString *)text { NSParameterAssert(text.length); diff --git a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m index c9a47ab..4331ad8 100644 --- a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m +++ b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m @@ -47,7 +47,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( #ifdef DEBUG // Verbose logs for debugging - //[Branch setDebug]; + [Branch setDebug]; #endif // Initiates a Branch session, and registers a callback. If you created a custom link with your own custom dictionary data, you probably want to know when the user session init finishes, so you can check that data. Think of this callback as your "deep link router". If your app opens with some data, you want to route the user depending on the data you passed in. Otherwise, send them to a generic install flow. From 444861a8868fb91e077abf2ce2a278d068f08cd7 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 10:32:29 -0500 Subject: [PATCH 23/49] Fixes reference to block self in callback block --- Overshare Kit/OSKShareableContent.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index 2ebe320..c0f7c13 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -46,7 +46,7 @@ - (void)processURLsForBranch { andCallback:^(NSString *url, NSError *error) { __strong OSKShareableContent *strongContent = weakContent; - NSString *channel = [self.channelsToProcessToBranch firstObject]; + NSString *channel = [strongContent.channelsToProcessToBranch firstObject]; if([channel isEqualToString:@"facebook"]) { strongContent.facebookItem.link = [NSURL URLWithString:url]; @@ -78,10 +78,10 @@ - (void)processURLsForBranch { } // Next channel - [self.channelsToProcessToBranch removeObjectAtIndex:0]; - if (self.channelsToProcessToBranch.count > 0) { + [strongContent.channelsToProcessToBranch removeObjectAtIndex:0]; + if (strongContent.channelsToProcessToBranch.count > 0) { NSLog(@"\n--------------------------------------\n"); - [self processURLsForBranch]; + [strongContent processURLsForBranch]; } }]; } From 1182bb33192d71e0886a12874a359390ab264130 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 11:01:12 -0500 Subject: [PATCH 24/49] Stubs out Channel array Closes #3 --- Overshare Kit/OSKShareableContent.m | 122 ++++++++++++++++------------ 1 file changed, 72 insertions(+), 50 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index c0f7c13..24b22a8 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -16,6 +16,29 @@ @implementation OSKShareableContent // --- Branch --- +- (void)initiateBranchWithURL:(NSURL *)url { + // Arrays of all channels + // Channels that have a url or link attribute + self.channelsToProcessToBranch = [@[ + @"facebook", + @"browser", + @"read_later", + @"bookmark", + @"microblog_twitter", + @"email", + @"sms", + @"todo", + @"text_editor", + @"airdrop" + ] mutableCopy]; + + // URL to process for each channel + self.urlToProcessToBranch = [url absoluteString]; + + // begin processing URLs for Branch + [self processURLsForBranch]; +} + - (void)processURLsForBranch { // Sinleton Branch instance @@ -46,35 +69,48 @@ - (void)processURLsForBranch { andCallback:^(NSString *url, NSError *error) { __strong OSKShareableContent *strongContent = weakContent; - NSString *channel = [strongContent.channelsToProcessToBranch firstObject]; - - if([channel isEqualToString:@"facebook"]) { - strongContent.facebookItem.link = [NSURL URLWithString:url]; - NSLog(@"Facebook: %@", strongContent.facebookItem.link); - } else if ([channel isEqualToString:@"browser"]) { - strongContent.webBrowserItem.url = [NSURL URLWithString:url]; - NSLog(@"Browser: %@", strongContent.webBrowserItem.url); - } else if ([channel isEqualToString:@"read_later"]) { - strongContent.readLaterItem.url = [NSURL URLWithString:url]; - NSLog(@"Read Later: %@", strongContent.readLaterItem.url); - } else if ([channel isEqualToString:@"bookmark"]) { - strongContent.linkBookmarkItem.url = [NSURL URLWithString:url]; - NSLog(@"Bookmark: %@", strongContent.linkBookmarkItem.url); - } else if ([channel isEqualToString:@"microblog_twitter"]) { - strongContent.microblogPostItem.text = [self branchifiedStringWithURL:url andOriginalString:strongContent.microblogPostItem.text]; - NSLog(@"Twitter / Microblog: %@", strongContent.microblogPostItem.text); - } else if ([channel isEqualToString:@"email"]) { - strongContent.emailItem.body = [self branchifiedStringWithURL:url andOriginalString:strongContent.emailItem.body]; - NSLog(@"Email: %@", strongContent.emailItem.body); - } else if ([channel isEqualToString:@"sms"]) { - strongContent.smsItem.body = [self branchifiedStringWithURL:url andOriginalString:strongContent.smsItem.body]; - NSLog(@"SMS: %@", strongContent.smsItem.body); - } else if ([channel isEqualToString:@"todo"]) { - strongContent.toDoListItem.notes = [ self branchifiedStringWithURL:url andOriginalString:strongContent.toDoListItem.notes]; - NSLog(@"Todo: %@", strongContent.toDoListItem.notes); - } else if ([channel isEqualToString:@"text_editor"]) { - strongContent.textEditingItem.text = [self branchifiedStringWithURL:url andOriginalString:strongContent.textEditingItem.text]; - NSLog(@"Text editor: %@", strongContent.textEditingItem.text); + if(!error) { + NSString *channel = [strongContent.channelsToProcessToBranch firstObject]; + + if([channel isEqualToString:@"facebook"]) { + strongContent.facebookItem.link = [NSURL URLWithString:url]; + NSLog(@"Facebook: %@", strongContent.facebookItem.link); + } else if ([channel isEqualToString:@"browser"]) { + strongContent.webBrowserItem.url = [NSURL URLWithString:url]; + NSLog(@"Browser: %@", strongContent.webBrowserItem.url); + } else if ([channel isEqualToString:@"read_later"]) { + strongContent.readLaterItem.url = [NSURL URLWithString:url]; + NSLog(@"Read Later: %@", strongContent.readLaterItem.url); + } else if ([channel isEqualToString:@"bookmark"]) { + strongContent.linkBookmarkItem.url = [NSURL URLWithString:url]; + NSLog(@"Bookmark: %@", strongContent.linkBookmarkItem.url); + } else if ([channel isEqualToString:@"microblog_twitter"]) { + strongContent.microblogPostItem.text = [self branchifiedStringWithURL:url andOriginalString:strongContent.microblogPostItem.text]; + NSLog(@"Twitter / Microblog: %@", strongContent.microblogPostItem.text); + } else if ([channel isEqualToString:@"email"]) { + strongContent.emailItem.body = [self branchifiedStringWithURL:url andOriginalString:strongContent.emailItem.body]; + NSLog(@"Email: %@", strongContent.emailItem.body); + } else if ([channel isEqualToString:@"sms"]) { + strongContent.smsItem.body = [self branchifiedStringWithURL:url andOriginalString:strongContent.smsItem.body]; + NSLog(@"SMS: %@", strongContent.smsItem.body); + } else if ([channel isEqualToString:@"todo"]) { + strongContent.toDoListItem.notes = [ self branchifiedStringWithURL:url andOriginalString:strongContent.toDoListItem.notes]; + NSLog(@"Todo: %@", strongContent.toDoListItem.notes); + } else if ([channel isEqualToString:@"text_editor"]) { + strongContent.textEditingItem.text = [self branchifiedStringWithURL:url andOriginalString:strongContent.textEditingItem.text]; + NSLog(@"Text editor: %@", strongContent.textEditingItem.text); + } else if ([channel isEqualToString:@"airdrop"]) { + NSMutableArray *airdropItems = [strongContent.airDropItem.items mutableCopy]; + for (int i = 0; i < [airdropItems count]; i++) { + if ([airdropItems[i] isKindOfClass:[NSString class]]) { + airdropItems[i] = + [self branchifiedStringWithURL:url + andOriginalString:airdropItems[i]]; + NSLog(@"AirDrop: %@", airdropItems[i]); + } + } + strongContent.airDropItem.items = airdropItems; + } } // Next channel @@ -215,6 +251,11 @@ + (instancetype)contentFromURL:(NSURL *)url { textEditing.text = url.absoluteString; content.textEditingItem = textEditing; + // Process all content for Branch URLs + if (url) { + [content initiateBranchWithURL:url]; + } + return content; } @@ -322,28 +363,9 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * textEditing.text = emailItem.body; content.textEditingItem = textEditing; - // Call Branch URLs + // Process all content for Branch URLs if (URLforCanonicalURL) { - - // Arrays of all channels - // Channels that have a url or link attribute - content.channelsToProcessToBranch = [@[ - @"facebook", - @"browser", - @"read_later", - @"bookmark", - @"microblog_twitter", - @"email", - @"sms", - @"todo", - @"text_editor" - ] mutableCopy]; - - // URL to process for each channel - content.urlToProcessToBranch = [URLforCanonicalURL absoluteString]; - - //Content iterms that have a url or link attribute - [content processURLsForBranch]; + [content initiateBranchWithURL:URLforCanonicalURL]; } return content; From b0e4ce9acf97fde5cd82901abbe8c264edb4a6b7 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 11:02:35 -0500 Subject: [PATCH 25/49] Comments out iOS and android URLs --- Overshare Kit/OSKShareableContent.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index 24b22a8..39d08e1 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -50,8 +50,8 @@ - (void)processURLsForBranch { //probably remove [params setObject:self.urlToProcessToBranch forKey:@"$desktop_url"]; //certainly remove - [params setObject:self.urlToProcessToBranch forKey:@"$ios_url"]; - [params setObject:self.urlToProcessToBranch forKey:@"$android_url"]; + //[params setObject:self.urlToProcessToBranch forKey:@"$ios_url"]; + //[params setObject:self.urlToProcessToBranch forKey:@"$android_url"]; // Weak block reference to self __weak OSKShareableContent *weakContent = self; From 5858214176a65f84b719a85759513cc26d5e039a Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 11:13:11 -0500 Subject: [PATCH 26/49] Fixes email subject line Changes email subject line in contentFromMicroblogPost from "Clipper Ships Sail On the Ocean" to "Link from %@", appName --- Overshare Kit/OSKShareableContent.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index 84a954f..93f85f9 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -125,6 +125,8 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * content.title = [NSString stringWithFormat:@"Post by %@: “%@”", authorName, text]; + NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; + NSURL *URLforCanonicalURL = nil; if (canonicalURL) { URLforCanonicalURL = [NSURL URLWithString:canonicalURL]; @@ -166,7 +168,7 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * OSKEmailContentItem *emailItem = [[OSKEmailContentItem alloc] init]; emailItem.body = [NSString stringWithFormat:@"“%@”\n\n(Via @%@)\n\n%@ ", text, authorName, canonicalURL]; - emailItem.subject = @"Clipper Ships Sail On the Ocean"; + emailItem.subject = [NSString stringWithFormat:@"Link from %@", appName]; emailItem.attachments = images.copy; content.emailItem = emailItem; @@ -185,7 +187,6 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * OSKLinkBookmarkContentItem *linkBookmarking = [[OSKLinkBookmarkContentItem alloc] init]; linkBookmarking.url = URLforCanonicalURL; linkBookmarking.notes = [NSString stringWithFormat:@"%@\n\n%@", text, canonicalURL]; - NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; linkBookmarking.tags = @[appName]; linkBookmarking.markToRead = YES; content.linkBookmarkItem = linkBookmarking; From eb7dc25ff690c6061e5b3dd1dbdb17e14c46e108 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 11:17:31 -0500 Subject: [PATCH 27/49] Adds comments for OG tags --- Overshare Kit/OSKShareableContent.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index 39d08e1..9fef489 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -47,12 +47,14 @@ - (void)processURLsForBranch { // Branch Link params NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; - //probably remove + // probably remove [params setObject:self.urlToProcessToBranch forKey:@"$desktop_url"]; //certainly remove //[params setObject:self.urlToProcessToBranch forKey:@"$ios_url"]; //[params setObject:self.urlToProcessToBranch forKey:@"$android_url"]; + // OG tags + // Weak block reference to self __weak OSKShareableContent *weakContent = self; From 5ab2f6b1ef826872b96d452803490ae632bb08b1 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 12:34:01 -0500 Subject: [PATCH 28/49] Adds Branch tracking tags extension to OSK Closes #5 --- Overshare Kit/OSKShareableContent.h | 32 +++++++++++- Overshare Kit/OSKShareableContent.m | 49 +++++++++++++++++-- .../Overshare/SampleTimelineViewController.m | 6 +++ 3 files changed, 83 insertions(+), 4 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.h b/Overshare Kit/OSKShareableContent.h index 8df3218..5f54423 100644 --- a/Overshare Kit/OSKShareableContent.h +++ b/Overshare Kit/OSKShareableContent.h @@ -152,7 +152,11 @@ These can be custom items, or additional instances of the official items above. @property (strong, nonatomic) NSString *branchStage; -@property (strong, nonatomic) NSString *branchAlias; +@property (strong, nonatomic) NSString *branchCampaign; + +@property (strong, nonatomic) NSDictionary *branchParams; + +@property (strong, nonatomic) NSDictionary *branchOGTags; // --- End Branch --- @end @@ -181,6 +185,32 @@ These can be custom items, or additional instances of the official items above. canonicalURL:(NSString *)canonicalURL images:(NSArray *)images; +// --- Branch --- +/** + Branch extensions to convenient constructors for microblog posts + */ + +// Tracking, OG, Deep link params, Stage, Feature, and Campagin tags ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags + branchOGTags:(NSDictionary *)branchOGTags + branchParams:(NSDictionary *)branchParams + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature + branchCampaign:(NSString *)branchCampaign; + +// Tracking tags ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags; + +// --- End Branch --- + /** Convenient constructor for sharing one or more images with a common caption. */ diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index f5bfb7b..e3a7880 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -53,7 +53,8 @@ - (void)processURLsForBranch { //[params setObject:self.urlToProcessToBranch forKey:@"$ios_url"]; //[params setObject:self.urlToProcessToBranch forKey:@"$android_url"]; - // OG tags + // Tracking tags + NSLog(@"Tags: %@", self.branchTags); // Weak block reference to self __weak OSKShareableContent *weakContent = self; @@ -67,7 +68,6 @@ - (void)processURLsForBranch { andChannel:channel andFeature:self.branchFeature andStage:self.branchStage - andAlias:self.branchAlias andCallback:^(NSString *url, NSError *error) { __strong OSKShareableContent *strongContent = weakContent; @@ -261,9 +261,27 @@ + (instancetype)contentFromURL:(NSURL *)url { return content; } -+ (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString *)authorName canonicalURL:(NSString *)canonicalURL images:(NSArray *)images { ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags + branchOGTags:(NSDictionary *)branchOGTags + branchParams:(NSDictionary *)branchParams + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature + branchCampaign:(NSString *)branchCampaign { + OSKShareableContent *content = [[OSKShareableContent alloc] init]; + // Branch arguments + content.branchTags = branchTrackingTags; + content.branchStage = branchStage; + content.branchFeature = branchFeature; + content.branchCampaign = branchCampaign; + content.branchParams = branchParams; + content.branchOGTags = branchOGTags; + content.title = [NSString stringWithFormat:@"Post by %@: “%@”", authorName, text]; NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; @@ -374,6 +392,31 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString * return content; } +// --- Branch --- + +/** + Original class allocation method without Branch arguments + */ ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:nil branchOGTags:nil branchParams:nil branchStage:nil branchFeature:nil branchCampaign:nil]; +} + +/** + Branch extensions to conveninvce constructors for Microblog posts + */ + +// Tracking tags ++ (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString *)authorName canonicalURL:(NSString *)canonicalURL images:(NSArray *)images branchTrackingTags:(NSArray *)branchTrackingTags { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchOGTags:nil branchParams:nil branchStage:nil branchFeature:nil branchCampaign:nil]; +} + +//--- End Branch --- + + (instancetype)contentFromImages:(NSArray *)images caption:(NSString *)caption { OSKShareableContent *content = [[OSKShareableContent alloc] init]; diff --git a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m index 563b4e3..624986a 100644 --- a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m +++ b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m @@ -77,10 +77,16 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { NSString *canonicalURL = @"http://github.com/overshare/overshare-kit"; NSString *authorName = @"testochango"; + /* OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images]; + */ + OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text + authorName:authorName canonicalURL:canonicalURL + images:images branchTrackingTags: + @[@"tag1", @"tag2"]]; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { [self showShareSheet_Phone:content]; From f5144cc069ece929792ca55ef6e8997f3d1751a9 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 13:00:09 -0500 Subject: [PATCH 29/49] Adds Branch params argument to OSK --- Overshare Kit/OSKShareableContent.h | 9 ++++- Overshare Kit/OSKShareableContent.m | 34 ++++++++++-------- .../Overshare/SampleTimelineViewController.m | 35 ++++++++++++++++--- 3 files changed, 57 insertions(+), 21 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.h b/Overshare Kit/OSKShareableContent.h index 5f54423..9ed5108 100644 --- a/Overshare Kit/OSKShareableContent.h +++ b/Overshare Kit/OSKShareableContent.h @@ -196,7 +196,6 @@ These can be custom items, or additional instances of the official items above. canonicalURL:(NSString *)canonicalURL images:(NSArray *)images branchTrackingTags:(NSArray *)branchTrackingTags - branchOGTags:(NSDictionary *)branchOGTags branchParams:(NSDictionary *)branchParams branchStage:(NSString *)branchStage branchFeature:(NSString *)branchFeature @@ -209,6 +208,14 @@ These can be custom items, or additional instances of the official items above. images:(NSArray *)images branchTrackingTags:(NSArray *)branchTrackingTags; +// Tracking Tags, Deep link params ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags + branchParams:(NSDictionary *)branchPrams; + // --- End Branch --- /** diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index e3a7880..0a75d79 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -44,15 +44,6 @@ - (void)processURLsForBranch { // Sinleton Branch instance Branch *branch = [Branch getInstance]; - // Branch Link params - NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; - - // probably remove - [params setObject:self.urlToProcessToBranch forKey:@"$desktop_url"]; - //certainly remove - //[params setObject:self.urlToProcessToBranch forKey:@"$ios_url"]; - //[params setObject:self.urlToProcessToBranch forKey:@"$android_url"]; - // Tracking tags NSLog(@"Tags: %@", self.branchTags); @@ -63,7 +54,7 @@ - (void)processURLsForBranch { // Content items that take a single URL as an argument // Create Branch Short URL for each channel - [branch getShortURLWithParams:params + [branch getShortURLWithParams:self.branchParams andTags:self.branchTags andChannel:channel andFeature:self.branchFeature @@ -266,7 +257,6 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text canonicalURL:(NSString *)canonicalURL images:(NSArray *)images branchTrackingTags:(NSArray *)branchTrackingTags - branchOGTags:(NSDictionary *)branchOGTags branchParams:(NSDictionary *)branchParams branchStage:(NSString *)branchStage branchFeature:(NSString *)branchFeature @@ -280,7 +270,6 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text content.branchFeature = branchFeature; content.branchCampaign = branchCampaign; content.branchParams = branchParams; - content.branchOGTags = branchOGTags; content.title = [NSString stringWithFormat:@"Post by %@: “%@”", authorName, text]; @@ -402,7 +391,7 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text canonicalURL:(NSString *)canonicalURL images:(NSArray *)images { - return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:nil branchOGTags:nil branchParams:nil branchStage:nil branchFeature:nil branchCampaign:nil]; + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:nil branchParams:nil branchStage:nil branchFeature:nil branchCampaign:nil]; } /** @@ -410,9 +399,24 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text */ // Tracking tags -+ (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString *)authorName canonicalURL:(NSString *)canonicalURL images:(NSArray *)images branchTrackingTags:(NSArray *)branchTrackingTags { ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchParams:nil branchStage:nil branchFeature:nil branchCampaign:nil]; +} + +// Tracking tags, Deep link params ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags + branchParams:(NSDictionary *)branchPrams { - return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchOGTags:nil branchParams:nil branchStage:nil branchFeature:nil branchCampaign:nil]; + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchParams:branchPrams branchStage:nil branchFeature:nil branchCampaign:nil]; } //--- End Branch --- diff --git a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m index 624986a..bb6fccc 100644 --- a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m +++ b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m @@ -77,16 +77,41 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { NSString *canonicalURL = @"http://github.com/overshare/overshare-kit"; NSString *authorName = @"testochango"; + // Original method call + /* + OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text + authorName:authorName + canonicalURL:canonicalURL + images:images]; + */ + + // --- Branch --- + // Sets up sample Branch data + NSArray *branchTags = @[@"test_tag1", @"test_tag2"]; + + NSMutableDictionary *branchParams = [[NSMutableDictionary alloc] init]; + // Example params + [branchParams setObject:@"Joe" forKey:@"user"]; + [branchParams setObject:@"https://s3-us-west-1.amazonaws.com/myapp/joes_pic.jpg" forKey:@"profile_pic"]; + [branchParams setObject:@"Joe likes long walks on the beach..." forKey:@"description"]; + + // Example OG params + [branchParams setObject:@"Joe is a super cool guy!" forKey:@"$og_title"]; + [branchParams setObject:@"https://s3-us-west-1.amazonaws.com/myapp/joes_pic.jpg" forKey:@"$og_image_url"]; + [branchParams setObject:@"Because he likes long walks on the beach..." forKey:@"$og_description"]; + + // Test Branch tags /* OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text - authorName:authorName - canonicalURL:canonicalURL - images:images]; + authorName:authorName canonicalURL:canonicalURL + images:images branchTrackingTags:branchTags]; */ + // Test Branch tags and params OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL - images:images branchTrackingTags: - @[@"tag1", @"tag2"]]; + images:images branchTrackingTags:branchTags branchParams:branchParams]; + + // --- End Branch --- if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { [self showShareSheet_Phone:content]; From 7498c6e33adb95f15683d92a09744f5713e39726 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 13:58:37 -0500 Subject: [PATCH 30/49] Remove campaign argument --- Overshare Kit/OSKShareableContent.h | 7 ++----- Overshare Kit/OSKShareableContent.m | 10 ++++----- .../Overshare/SampleTimelineViewController.m | 21 +++++++++++++------ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.h b/Overshare Kit/OSKShareableContent.h index 9ed5108..d099e39 100644 --- a/Overshare Kit/OSKShareableContent.h +++ b/Overshare Kit/OSKShareableContent.h @@ -152,8 +152,6 @@ These can be custom items, or additional instances of the official items above. @property (strong, nonatomic) NSString *branchStage; -@property (strong, nonatomic) NSString *branchCampaign; - @property (strong, nonatomic) NSDictionary *branchParams; @property (strong, nonatomic) NSDictionary *branchOGTags; @@ -190,7 +188,7 @@ These can be custom items, or additional instances of the official items above. Branch extensions to convenient constructors for microblog posts */ -// Tracking, OG, Deep link params, Stage, Feature, and Campagin tags +// Tracking, OG, Deep link params, Stage, Feature, and Campaign tags + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString *)authorName canonicalURL:(NSString *)canonicalURL @@ -198,8 +196,7 @@ These can be custom items, or additional instances of the official items above. branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary *)branchParams branchStage:(NSString *)branchStage - branchFeature:(NSString *)branchFeature - branchCampaign:(NSString *)branchCampaign; + branchFeature:(NSString *)branchFeature; // Tracking tags + (instancetype)contentFromMicroblogPost:(NSString *)text diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index 0a75d79..4e6763c 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -259,8 +259,7 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary *)branchParams branchStage:(NSString *)branchStage - branchFeature:(NSString *)branchFeature - branchCampaign:(NSString *)branchCampaign { + branchFeature:(NSString *)branchFeature { OSKShareableContent *content = [[OSKShareableContent alloc] init]; @@ -268,7 +267,6 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text content.branchTags = branchTrackingTags; content.branchStage = branchStage; content.branchFeature = branchFeature; - content.branchCampaign = branchCampaign; content.branchParams = branchParams; content.title = [NSString stringWithFormat:@"Post by %@: “%@”", authorName, text]; @@ -391,7 +389,7 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text canonicalURL:(NSString *)canonicalURL images:(NSArray *)images { - return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:nil branchParams:nil branchStage:nil branchFeature:nil branchCampaign:nil]; + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:nil branchParams:nil branchStage:nil branchFeature:nil]; } /** @@ -405,7 +403,7 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text images:(NSArray *)images branchTrackingTags:(NSArray *)branchTrackingTags { - return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchParams:nil branchStage:nil branchFeature:nil branchCampaign:nil]; + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchParams:nil branchStage:nil branchFeature:nil]; } // Tracking tags, Deep link params @@ -416,7 +414,7 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary *)branchPrams { - return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchParams:branchPrams branchStage:nil branchFeature:nil branchCampaign:nil]; + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchParams:branchPrams branchStage:nil branchFeature:nil]; } //--- End Branch --- diff --git a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m index bb6fccc..718f9e8 100644 --- a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m +++ b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m @@ -80,9 +80,9 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { // Original method call /* OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text - authorName:authorName - canonicalURL:canonicalURL - images:images]; + authorName:authorName + canonicalURL:canonicalURL + images:images]; */ // --- Branch --- @@ -90,7 +90,7 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { NSArray *branchTags = @[@"test_tag1", @"test_tag2"]; NSMutableDictionary *branchParams = [[NSMutableDictionary alloc] init]; - // Example params + // Example params Deep Link data [branchParams setObject:@"Joe" forKey:@"user"]; [branchParams setObject:@"https://s3-us-west-1.amazonaws.com/myapp/joes_pic.jpg" forKey:@"profile_pic"]; [branchParams setObject:@"Joe likes long walks on the beach..." forKey:@"description"]; @@ -100,13 +100,22 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { [branchParams setObject:@"https://s3-us-west-1.amazonaws.com/myapp/joes_pic.jpg" forKey:@"$og_image_url"]; [branchParams setObject:@"Because he likes long walks on the beach..." forKey:@"$og_description"]; - // Test Branch tags + // Example Stage + NSString *branchStage = @"test_stage"; + + // Example Feature + NSString *branchFeature = @"test_feature"; + + // Example Campaign + NSString *branchCampaign = @"test_campaign"; + + // OSK with Branch tags /* OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTags]; */ - // Test Branch tags and params + // OSK with Branch tags and Params OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTags branchParams:branchParams]; From b5ea3c0710d50cd53ecdf2ddf3e9791dba34c2dd Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 14:03:09 -0500 Subject: [PATCH 31/49] Extends OSK for just deep links --- Overshare Kit/OSKShareableContent.h | 7 +++++++ Overshare Kit/OSKShareableContent.m | 10 ++++++++++ .../Overshare/SampleTimelineViewController.m | 14 ++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.h b/Overshare Kit/OSKShareableContent.h index d099e39..d20e44d 100644 --- a/Overshare Kit/OSKShareableContent.h +++ b/Overshare Kit/OSKShareableContent.h @@ -213,6 +213,13 @@ These can be custom items, or additional instances of the official items above. branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary *)branchPrams; +// Deep link params ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchParams:(NSDictionary *)branchPrams; + // --- End Branch --- /** diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index 4e6763c..dd93896 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -417,6 +417,16 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchParams:branchPrams branchStage:nil branchFeature:nil]; } +// Deep link params ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchParams:(NSDictionary *)branchPrams { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:nil branchParams:branchPrams branchStage:nil branchFeature:nil]; +} + //--- End Branch --- + (instancetype)contentFromImages:(NSArray *)images caption:(NSString *)caption { diff --git a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m index 718f9e8..cb2b5e0 100644 --- a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m +++ b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m @@ -97,7 +97,7 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { // Example OG params [branchParams setObject:@"Joe is a super cool guy!" forKey:@"$og_title"]; - [branchParams setObject:@"https://s3-us-west-1.amazonaws.com/myapp/joes_pic.jpg" forKey:@"$og_image_url"]; + [branchParams setObject:@"https://branch.io/img/logo_icon_black.png" forKey:@"$og_image_url"]; [branchParams setObject:@"Because he likes long walks on the beach..." forKey:@"$og_description"]; // Example Stage @@ -115,10 +115,20 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTags]; */ - // OSK with Branch tags and Params + + // OSK with Branch tags and Params for deep links + /* OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTags branchParams:branchParams]; + */ + + // OSK with Params for deep links + OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text + authorName:authorName + canonicalURL:canonicalURL + images:images + branchParams:branchParams]; // --- End Branch --- From 8cea158d50490cceb6e478856dffaed3bc444254 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 14:09:24 -0500 Subject: [PATCH 32/49] Extends OSK content with Branch Stage --- Overshare Kit/OSKShareableContent.h | 34 +++++++++++++- Overshare Kit/OSKShareableContent.m | 44 +++++++++++++++++++ .../Overshare/SampleTimelineViewController.m | 13 ++++-- 3 files changed, 87 insertions(+), 4 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.h b/Overshare Kit/OSKShareableContent.h index d20e44d..313fe03 100644 --- a/Overshare Kit/OSKShareableContent.h +++ b/Overshare Kit/OSKShareableContent.h @@ -188,7 +188,7 @@ These can be custom items, or additional instances of the official items above. Branch extensions to convenient constructors for microblog posts */ -// Tracking, OG, Deep link params, Stage, Feature, and Campaign tags +// All Branch Arguments: Tracking, OG, Deep link params, Stage, Feature, and Campaign tags + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString *)authorName canonicalURL:(NSString *)canonicalURL @@ -220,6 +220,38 @@ These can be custom items, or additional instances of the official items above. images:(NSArray *)images branchParams:(NSDictionary *)branchPrams; +// Tracking Tags, Deep link params, Stage ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags + branchParams:(NSDictionary *)branchPrams + branchStage:(NSString *)branchStage; + +// Deep link params, Stage ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchParams:(NSDictionary *)branchPrams + branchStage:(NSString *)branchStage; + +// Tracking Tags, Stage ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags + branchStage:(NSString *)branchStage; + +// Stage ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchStage:(NSString *)branchStage; + // --- End Branch --- /** diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index dd93896..1aa16c8 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -427,6 +427,50 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:nil branchParams:branchPrams branchStage:nil branchFeature:nil]; } +// Tracking Tags, Deep link params, Stage ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags + branchParams:(NSDictionary *)branchPrams + branchStage:(NSString *)branchStage { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchParams:branchPrams branchStage:branchStage branchFeature:nil]; +} + +// Deep link params, Stage ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchParams:(NSDictionary *)branchPrams + branchStage:(NSString *)branchStage { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:nil branchParams:branchPrams branchStage:branchStage branchFeature:nil]; +}; + +// Tracking Tags, Stage ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags + branchStage:(NSString *)branchStage { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchParams:nil branchStage:branchStage branchFeature:nil]; +}; + +// Stage ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchStage:(NSString *)branchStage { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:nil branchParams:nil branchStage:branchStage branchFeature:nil]; +}; + //--- End Branch --- + (instancetype)contentFromImages:(NSArray *)images caption:(NSString *)caption { diff --git a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m index cb2b5e0..8d019a6 100644 --- a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m +++ b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m @@ -106,9 +106,6 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { // Example Feature NSString *branchFeature = @"test_feature"; - // Example Campaign - NSString *branchCampaign = @"test_campaign"; - // OSK with Branch tags /* OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text @@ -124,11 +121,21 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { */ // OSK with Params for deep links + /* OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchParams:branchParams]; + */ + // OSK with Branch tags and Params for deep links + OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text + authorName:authorName + canonicalURL:canonicalURL + images:images + branchTrackingTags:branchTags + branchParams:branchParams + branchStage:branchStage]; // --- End Branch --- From a387b16df7f26b014ec5d5f93d4661c873ac0d06 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 14:11:57 -0500 Subject: [PATCH 33/49] Adds examples of Branch stage implementation --- .../Overshare/SampleTimelineViewController.m | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m index 8d019a6..2b26084 100644 --- a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m +++ b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m @@ -128,7 +128,8 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { images:images branchParams:branchParams]; */ - // OSK with Branch tags and Params for deep links + // OSK with Branch tags, Params for deep links, and Branch Stage + /* OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL @@ -136,6 +137,34 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { branchTrackingTags:branchTags branchParams:branchParams branchStage:branchStage]; + */ + + // OSK with Branch tags and Branch Stage + /* + OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text + authorName:authorName + canonicalURL:canonicalURL + images:images + branchTrackingTags:branchTags + branchStage:branchStage]; + */ + + // OSK with Branch Params for deep links and Branch Stage + /* + OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text + authorName:authorName + canonicalURL:canonicalURL + images:images + branchParams:branchParams + branchStage:branchStage]; + */ + + // OSK with Branch Stage + OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text + authorName:authorName + canonicalURL:canonicalURL + images:images + branchStage:branchStage]; // --- End Branch --- From daa6b8c036f0829e5f33f5fbb3bb9d0bae21782e Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 14:26:04 -0500 Subject: [PATCH 34/49] Extends OSK for Branch Feature argument --- Overshare Kit/OSKShareableContent.h | 67 +++++++++++++++++++++- Overshare Kit/OSKShareableContent.m | 86 +++++++++++++++++++++++++++-- 2 files changed, 147 insertions(+), 6 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.h b/Overshare Kit/OSKShareableContent.h index 313fe03..d21bd99 100644 --- a/Overshare Kit/OSKShareableContent.h +++ b/Overshare Kit/OSKShareableContent.h @@ -188,7 +188,7 @@ These can be custom items, or additional instances of the official items above. Branch extensions to convenient constructors for microblog posts */ -// All Branch Arguments: Tracking, OG, Deep link params, Stage, Feature, and Campaign tags +// All Branch Arguments: Tracking, Deep link params, Stage, and Feature + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString *)authorName canonicalURL:(NSString *)canonicalURL @@ -252,6 +252,64 @@ These can be custom items, or additional instances of the official items above. images:(NSArray *)images branchStage:(NSString *)branchStage; +// Tracking tags, Deep link params, and Feature ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags + branchParams:(NSDictionary *)branchParams + branchFeature:(NSString *)branchFeature; + +// Tracking tags, Stage, and Feature ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature; + +// Deep link params, Stage and Feature ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchParams:(NSDictionary *)branchParams + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature; + +// Deep link params and Feature ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchParams:(NSDictionary *)branchParams + branchFeature:(NSString *)branchFeature; + +// Stage and Feature ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature; + +// Tracking tags and Feature ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags + branchFeature:(NSString *)branchFeature; + +// Feature ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchFeature:(NSString *)branchFeature; + // --- End Branch --- /** @@ -260,8 +318,15 @@ These can be custom items, or additional instances of the official items above. + (instancetype)contentFromImages:(NSArray *)images caption:(NSString *)caption; +// --- Branch --- + +/** + Processes URLs in all Content Items and replaces with Branch URLs + */ - (void)processURLsForBranch; +// --- Branch --- + @end diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index 1aa16c8..7f1771e 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -44,9 +44,6 @@ - (void)processURLsForBranch { // Sinleton Branch instance Branch *branch = [Branch getInstance]; - // Tracking tags - NSLog(@"Tags: %@", self.branchTags); - // Weak block reference to self __weak OSKShareableContent *weakContent = self; @@ -382,7 +379,7 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text // --- Branch --- /** - Original class allocation method without Branch arguments + Original class method without Branch arguments */ + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString *)authorName @@ -393,7 +390,7 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text } /** - Branch extensions to conveninvce constructors for Microblog posts + Branch extensions to convenient constructors for Microblog posts */ // Tracking tags @@ -461,6 +458,85 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchParams:nil branchStage:branchStage branchFeature:nil]; }; +// Tracking tags, Deep link params, and Feature ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags + branchParams:(NSDictionary *)branchParams + branchFeature:(NSString *)branchFeature { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchParams:branchParams branchStage:nil branchFeature:branchFeature]; +}; + +// Tracking tags, Stage, and Feature ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchParams:nil branchStage:branchStage branchFeature:branchFeature]; +}; + +// Deep link params, Stage and Feature ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchParams:(NSDictionary *)branchParams + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:nil branchParams:branchParams branchStage:branchStage branchFeature:branchFeature]; +}; + +// Deep link params and Feature ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchParams:(NSDictionary *)branchParams + branchFeature:(NSString *)branchFeature { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:nil branchParams:branchParams branchStage:nil branchFeature:branchFeature]; +}; + +// Stage and Feature ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:nil branchParams:nil branchStage:branchStage branchFeature:branchFeature]; +}; + +// Tracking tags and Feature ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchTrackingTags:(NSArray *)branchTrackingTags + branchFeature:(NSString *)branchFeature { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTrackingTags branchParams:nil branchStage:nil branchFeature:branchFeature]; +}; + +// Feature ++ (instancetype)contentFromMicroblogPost:(NSString *)text + authorName:(NSString *)authorName + canonicalURL:(NSString *)canonicalURL + images:(NSArray *)images + branchFeature:(NSString *)branchFeature { + + return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:nil branchParams:nil branchStage:nil branchFeature:branchFeature]; +}; + // Stage + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString *)authorName From 5d2e79423a3cdf469d86a0cce211aa79b2bb18e5 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 14:34:52 -0500 Subject: [PATCH 35/49] Adds commenting and final example OSK content --- .../Overshare/SampleTimelineViewController.m | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m index 2b26084..7603d52 100644 --- a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m +++ b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m @@ -86,6 +86,7 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { */ // --- Branch --- + // Sets up sample Branch data NSArray *branchTags = @[@"test_tag1", @"test_tag2"]; @@ -95,7 +96,7 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { [branchParams setObject:@"https://s3-us-west-1.amazonaws.com/myapp/joes_pic.jpg" forKey:@"profile_pic"]; [branchParams setObject:@"Joe likes long walks on the beach..." forKey:@"description"]; - // Example OG params + // Example OG params (for social media... http://ogp.me/) [branchParams setObject:@"Joe is a super cool guy!" forKey:@"$og_title"]; [branchParams setObject:@"https://branch.io/img/logo_icon_black.png" forKey:@"$og_image_url"]; [branchParams setObject:@"Because he likes long walks on the beach..." forKey:@"$og_description"]; @@ -106,8 +107,19 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { // Example Feature NSString *branchFeature = @"test_feature"; - // OSK with Branch tags + // OSK Content with Branch tags exmaples... + + // OSK Content with all arguments + OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text + authorName:authorName + canonicalURL:canonicalURL + images:images + branchTrackingTags:branchTags + branchParams:branchParams + branchStage:branchStage + branchFeature:branchFeature]; /* + // OSK with tracking tags OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:branchTags]; @@ -160,11 +172,22 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { */ // OSK with Branch Stage + /* OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchStage:branchStage]; + */ + + // OSK with Branch Feature + /* + OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text + authorName:authorName + canonicalURL:canonicalURL + images:images + branchFeature:branchFeature]; + */ // --- End Branch --- From 8862470e4edca551ebcde50f3f07bbb12f6d3b19 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 14:52:57 -0500 Subject: [PATCH 36/49] Moves Branch methods to end --- Overshare Kit/OSKShareableContent.m | 244 ++++++++++++++-------------- 1 file changed, 122 insertions(+), 122 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index 7f1771e..b363b6e 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -14,128 +14,6 @@ @implementation OSKShareableContent -// --- Branch --- - -- (void)initiateBranchWithURL:(NSURL *)url { - // Arrays of all channels - // Channels that have a url or link attribute - self.channelsToProcessToBranch = [@[ - @"facebook", - @"browser", - @"read_later", - @"bookmark", - @"microblog_twitter", - @"email", - @"sms", - @"todo", - @"text_editor", - @"airdrop" - ] mutableCopy]; - - // URL to process for each channel - self.urlToProcessToBranch = [url absoluteString]; - - // begin processing URLs for Branch - [self processURLsForBranch]; -} - -- (void)processURLsForBranch { - - // Sinleton Branch instance - Branch *branch = [Branch getInstance]; - - // Weak block reference to self - __weak OSKShareableContent *weakContent = self; - - NSString *channel = [self.channelsToProcessToBranch firstObject]; - - // Content items that take a single URL as an argument - // Create Branch Short URL for each channel - [branch getShortURLWithParams:self.branchParams - andTags:self.branchTags - andChannel:channel - andFeature:self.branchFeature - andStage:self.branchStage - andCallback:^(NSString *url, NSError *error) { - __strong OSKShareableContent *strongContent = weakContent; - - if(!error) { - NSString *channel = [strongContent.channelsToProcessToBranch firstObject]; - - if([channel isEqualToString:@"facebook"]) { - strongContent.facebookItem.link = [NSURL URLWithString:url]; - NSLog(@"Facebook: %@", strongContent.facebookItem.link); - } else if ([channel isEqualToString:@"browser"]) { - strongContent.webBrowserItem.url = [NSURL URLWithString:url]; - NSLog(@"Browser: %@", strongContent.webBrowserItem.url); - } else if ([channel isEqualToString:@"read_later"]) { - strongContent.readLaterItem.url = [NSURL URLWithString:url]; - NSLog(@"Read Later: %@", strongContent.readLaterItem.url); - } else if ([channel isEqualToString:@"bookmark"]) { - strongContent.linkBookmarkItem.url = [NSURL URLWithString:url]; - NSLog(@"Bookmark: %@", strongContent.linkBookmarkItem.url); - } else if ([channel isEqualToString:@"microblog_twitter"]) { - strongContent.microblogPostItem.text = [self branchifiedStringWithURL:url andOriginalString:strongContent.microblogPostItem.text]; - NSLog(@"Twitter / Microblog: %@", strongContent.microblogPostItem.text); - } else if ([channel isEqualToString:@"email"]) { - strongContent.emailItem.body = [self branchifiedStringWithURL:url andOriginalString:strongContent.emailItem.body]; - NSLog(@"Email: %@", strongContent.emailItem.body); - } else if ([channel isEqualToString:@"sms"]) { - strongContent.smsItem.body = [self branchifiedStringWithURL:url andOriginalString:strongContent.smsItem.body]; - NSLog(@"SMS: %@", strongContent.smsItem.body); - } else if ([channel isEqualToString:@"todo"]) { - strongContent.toDoListItem.notes = [ self branchifiedStringWithURL:url andOriginalString:strongContent.toDoListItem.notes]; - NSLog(@"Todo: %@", strongContent.toDoListItem.notes); - } else if ([channel isEqualToString:@"text_editor"]) { - strongContent.textEditingItem.text = [self branchifiedStringWithURL:url andOriginalString:strongContent.textEditingItem.text]; - NSLog(@"Text editor: %@", strongContent.textEditingItem.text); - } else if ([channel isEqualToString:@"airdrop"]) { - NSMutableArray *airdropItems = [strongContent.airDropItem.items mutableCopy]; - for (int i = 0; i < [airdropItems count]; i++) { - if ([airdropItems[i] isKindOfClass:[NSString class]]) { - airdropItems[i] = - [self branchifiedStringWithURL:url - andOriginalString:airdropItems[i]]; - NSLog(@"AirDrop: %@", airdropItems[i]); - } - } - strongContent.airDropItem.items = airdropItems; - } - } - - // Next channel - [strongContent.channelsToProcessToBranch removeObjectAtIndex:0]; - if (strongContent.channelsToProcessToBranch.count > 0) { - NSLog(@"\n--------------------------------------\n"); - [strongContent processURLsForBranch]; - } - }]; -} - -// Processes strings of content, and replaces the URL at the end with the Branch URL provided -- (NSString *)branchifiedStringWithURL:(NSString *)branchURL andOriginalString:(NSString *)string { - // Identifies all links in a string - NSTextCheckingResult *urlCheckingResult = [self identifyAllUrlsAndReplaceInString:string]; - - // Remove the original URL from the end of the string - NSString *truncatedString = [string stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; - - // Append the original string with the Branch URL and return - return [truncatedString stringByAppendingString:branchURL]; -} - -// identifies all links in a string -- (NSTextCheckingResult *)identifyAllUrlsAndReplaceInString:(NSString *)string { - // Find all URLs in a string - NSDataDetector *detect = [[NSDataDetector alloc] initWithTypes:NSTextCheckingTypeLink error:nil]; - NSMutableArray *allURLs = [[detect matchesInString:string options:0 range:NSMakeRange(0, [string length])] mutableCopy]; - - //return the URL checking result at the end of the string - return [allURLs lastObject]; -} - -// --- End Branch --- - + (instancetype)contentFromText:(NSString *)text { NSParameterAssert(text.length); @@ -641,6 +519,128 @@ + (instancetype)contentFromImages:(NSArray *)images caption:(NSString *)caption return content; } +// --- Branch --- + +- (void)initiateBranchWithURL:(NSURL *)url { + // Arrays of all channels + // Channels that have a url or link attribute + self.channelsToProcessToBranch = [@[ + @"facebook", + @"browser", + @"read_later", + @"bookmark", + @"microblog_twitter", + @"email", + @"sms", + @"todo", + @"text_editor", + @"airdrop" + ] mutableCopy]; + + // URL to process for each channel + self.urlToProcessToBranch = [url absoluteString]; + + // begin processing URLs for Branch + [self processURLsForBranch]; +} + +- (void)processURLsForBranch { + + // Sinleton Branch instance + Branch *branch = [Branch getInstance]; + + // Weak block reference to self + __weak OSKShareableContent *weakContent = self; + + NSString *channel = [self.channelsToProcessToBranch firstObject]; + + // Content items that take a single URL as an argument + // Create Branch Short URL for each channel + [branch getShortURLWithParams:self.branchParams + andTags:self.branchTags + andChannel:channel + andFeature:self.branchFeature + andStage:self.branchStage + andCallback:^(NSString *url, NSError *error) { + __strong OSKShareableContent *strongContent = weakContent; + + if(!error) { + NSString *channel = [strongContent.channelsToProcessToBranch firstObject]; + + if([channel isEqualToString:@"facebook"]) { + strongContent.facebookItem.link = [NSURL URLWithString:url]; + NSLog(@"Facebook: %@", strongContent.facebookItem.link); + } else if ([channel isEqualToString:@"browser"]) { + strongContent.webBrowserItem.url = [NSURL URLWithString:url]; + NSLog(@"Browser: %@", strongContent.webBrowserItem.url); + } else if ([channel isEqualToString:@"read_later"]) { + strongContent.readLaterItem.url = [NSURL URLWithString:url]; + NSLog(@"Read Later: %@", strongContent.readLaterItem.url); + } else if ([channel isEqualToString:@"bookmark"]) { + strongContent.linkBookmarkItem.url = [NSURL URLWithString:url]; + NSLog(@"Bookmark: %@", strongContent.linkBookmarkItem.url); + } else if ([channel isEqualToString:@"microblog_twitter"]) { + strongContent.microblogPostItem.text = [self branchifiedStringWithURL:url andOriginalString:strongContent.microblogPostItem.text]; + NSLog(@"Twitter / Microblog: %@", strongContent.microblogPostItem.text); + } else if ([channel isEqualToString:@"email"]) { + strongContent.emailItem.body = [self branchifiedStringWithURL:url andOriginalString:strongContent.emailItem.body]; + NSLog(@"Email: %@", strongContent.emailItem.body); + } else if ([channel isEqualToString:@"sms"]) { + strongContent.smsItem.body = [self branchifiedStringWithURL:url andOriginalString:strongContent.smsItem.body]; + NSLog(@"SMS: %@", strongContent.smsItem.body); + } else if ([channel isEqualToString:@"todo"]) { + strongContent.toDoListItem.notes = [ self branchifiedStringWithURL:url andOriginalString:strongContent.toDoListItem.notes]; + NSLog(@"Todo: %@", strongContent.toDoListItem.notes); + } else if ([channel isEqualToString:@"text_editor"]) { + strongContent.textEditingItem.text = [self branchifiedStringWithURL:url andOriginalString:strongContent.textEditingItem.text]; + NSLog(@"Text editor: %@", strongContent.textEditingItem.text); + } else if ([channel isEqualToString:@"airdrop"]) { + NSMutableArray *airdropItems = [strongContent.airDropItem.items mutableCopy]; + for (int i = 0; i < [airdropItems count]; i++) { + if ([airdropItems[i] isKindOfClass:[NSString class]]) { + airdropItems[i] = + [self branchifiedStringWithURL:url + andOriginalString:airdropItems[i]]; + NSLog(@"AirDrop: %@", airdropItems[i]); + } + } + strongContent.airDropItem.items = airdropItems; + } + } + + // Next channel + [strongContent.channelsToProcessToBranch removeObjectAtIndex:0]; + if (strongContent.channelsToProcessToBranch.count > 0) { + NSLog(@"\n--------------------------------------\n"); + [strongContent processURLsForBranch]; + } + }]; +} + +// Processes strings of content, and replaces the URL at the end with the Branch URL provided +- (NSString *)branchifiedStringWithURL:(NSString *)branchURL andOriginalString:(NSString *)string { + // Identifies all links in a string + NSTextCheckingResult *urlCheckingResult = [self identifyAllUrlsAndReplaceInString:string]; + + // Remove the original URL from the end of the string + NSString *truncatedString = [string stringByReplacingCharactersInRange:urlCheckingResult.range withString:@""]; + + // Append the original string with the Branch URL and return + return [truncatedString stringByAppendingString:branchURL]; +} + +// identifies all links in a string +- (NSTextCheckingResult *)identifyAllUrlsAndReplaceInString:(NSString *)string { + // Find all URLs in a string + NSDataDetector *detect = [[NSDataDetector alloc] initWithTypes:NSTextCheckingTypeLink error:nil]; + NSMutableArray *allURLs = [[detect matchesInString:string options:0 range:NSMakeRange(0, [string length])] mutableCopy]; + + //return the URL checking result at the end of the string + return [allURLs lastObject]; +} + +// --- End Branch --- + - (instancetype)init { self = [super init]; if (self) { From 13834e607d8b37d1139d692c183ccddad5990d18 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 15:04:46 -0500 Subject: [PATCH 37/49] Adds OSK Content URL Methods --- Overshare Kit/OSKShareableContent.h | 84 ++++++++++++ Overshare Kit/OSKShareableContent.m | 197 +++++++++++++++++++++++++++- 2 files changed, 280 insertions(+), 1 deletion(-) diff --git a/Overshare Kit/OSKShareableContent.h b/Overshare Kit/OSKShareableContent.h index d21bd99..485bb64 100644 --- a/Overshare Kit/OSKShareableContent.h +++ b/Overshare Kit/OSKShareableContent.h @@ -175,6 +175,90 @@ These can be custom items, or additional instances of the official items above. */ + (instancetype)contentFromURL:(NSURL *)url; +// --- Branch --- +/** + Branch extensions to convenient constructors for links + */ + +// All Branch Arguments: Tracking, Deep link params, Stage, and Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags + branchParams:(NSDictionary *)branchParams + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature; + +// Tracking tags ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags; + +// Tracking Tags, Deep link params ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags + branchParams:(NSDictionary *)branchPrams; + +// Deep link params ++ (instancetype)contentFromURL:(NSURL *)url + branchParams:(NSDictionary *)branchPrams; + +// Tracking Tags, Deep link params, Stage ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags + branchParams:(NSDictionary *)branchPrams + branchStage:(NSString *)branchStage; + +// Deep link params, Stage ++ (instancetype)contentFromURL:(NSURL *)url + branchParams:(NSDictionary *)branchPrams + branchStage:(NSString *)branchStage; + +// Tracking Tags, Stage ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags + branchStage:(NSString *)branchStage; + +// Stage ++ (instancetype)contentFromURL:(NSURL *)url + branchStage:(NSString *)branchStage; + +// Tracking tags, Deep link params, and Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags + branchParams:(NSDictionary *)branchParams + branchFeature:(NSString *)branchFeature; + +// Tracking tags, Stage, and Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature; + +// Deep link params, Stage and Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchParams:(NSDictionary *)branchParams + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature; + +// Deep link params and Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchParams:(NSDictionary *)branchParams + branchFeature:(NSString *)branchFeature; + +// Stage and Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature; + +// Tracking tags and Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags + branchFeature:(NSString *)branchFeature; + +// Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchFeature:(NSString *)branchFeature; + +// --- End Branch --- + /** Convenient constructor for content drawn from microblog posts (like Twitter or App.net). */ diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index b363b6e..3399fa4 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -56,10 +56,21 @@ + (instancetype)contentFromText:(NSString *)text { return content; } -+ (instancetype)contentFromURL:(NSURL *)url { ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags + branchParams:(NSDictionary *)branchParams + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature { NSParameterAssert(url.absoluteString.length); OSKShareableContent *content = [[OSKShareableContent alloc] init]; + + // Branch arguments + content.branchTags = branchTrackingTags; + content.branchStage = branchStage; + content.branchFeature = branchFeature; + content.branchParams = branchParams; + NSString *absoluteString = url.absoluteString; content.title = absoluteString; @@ -127,6 +138,190 @@ + (instancetype)contentFromURL:(NSURL *)url { return content; } +// --- Branch --- + +/** + Original class method without Branch arguments + */ ++ (instancetype)contentFromURL:(NSURL *)url { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:nil + branchParams:nil + branchStage:nil + branchFeature:nil]; +}; + +// Tracking tags ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:branchTrackingTags + branchParams:nil + branchStage:nil + branchFeature:nil]; +}; + +// Tracking Tags, Deep link params ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags + branchParams:(NSDictionary *)branchPrams { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:branchTrackingTags + branchParams:branchPrams + branchStage:nil + branchFeature:nil]; +}; + +// Deep link params ++ (instancetype)contentFromURL:(NSURL *)url + branchParams:(NSDictionary *)branchPrams { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:nil + branchParams:branchPrams + branchStage:nil + branchFeature:nil]; +}; + +// Tracking Tags, Deep link params, Stage ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags + branchParams:(NSDictionary *)branchPrams + branchStage:(NSString *)branchStage { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:branchTrackingTags + branchParams:branchPrams + branchStage:branchStage + branchFeature:nil]; +}; + +// Deep link params, Stage ++ (instancetype)contentFromURL:(NSURL *)url + branchParams:(NSDictionary *)branchPrams + branchStage:(NSString *)branchStage { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:nil + branchParams:branchPrams + branchStage:branchStage + branchFeature:nil]; +}; + +// Tracking Tags, Stage ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags + branchStage:(NSString *)branchStage { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:branchTrackingTags + branchParams:nil + branchStage:branchStage + branchFeature:nil]; +}; + +// Stage ++ (instancetype)contentFromURL:(NSURL *)url + branchStage:(NSString *)branchStage { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:nil + branchParams:nil + branchStage:branchStage + branchFeature:nil]; +}; + +// Tracking tags, Deep link params, and Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags + branchParams:(NSDictionary *)branchParams + branchFeature:(NSString *)branchFeature { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:branchTrackingTags + branchParams:branchParams + branchStage:nil + branchFeature:branchFeature]; +}; + +// Tracking tags, Stage, and Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:branchTrackingTags + branchParams:nil + branchStage:branchStage + branchFeature:branchFeature]; +}; + +// Deep link params, Stage and Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchParams:(NSDictionary *)branchParams + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:nil + branchParams:branchParams + branchStage:branchStage + branchFeature:branchFeature]; +}; + +// Deep link params and Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchParams:(NSDictionary *)branchParams + branchFeature:(NSString *)branchFeature { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:nil + branchParams:branchParams + branchStage:nil + branchFeature:branchFeature]; +}; + +// Stage and Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchStage:(NSString *)branchStage + branchFeature:(NSString *)branchFeature { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:nil + branchParams:nil + branchStage:branchStage + branchFeature:branchFeature]; +}; + +// Tracking tags and Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchTrackingTags:(NSArray *)branchTrackingTags + branchFeature:(NSString *)branchFeature { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:branchTrackingTags + branchParams:nil + branchStage:nil + branchFeature:branchFeature]; +}; + +// Feature ++ (instancetype)contentFromURL:(NSURL *)url + branchFeature:(NSString *)branchFeature { + + return [OSKShareableContent contentFromURL:url + branchTrackingTags:nil + branchParams:nil + branchStage:nil + branchFeature:branchFeature]; +}; + +// --- End Branch --- + + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString *)authorName canonicalURL:(NSString *)canonicalURL From 888ffe733f2222570c16f99cc0010220141c5f07 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Fri, 23 Jan 2015 15:45:33 -0500 Subject: [PATCH 38/49] Initial instructions in README --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 912a422..0d3d50a 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ OvershareKit - [URL Schemes](#url-schemes) - [Dependencies](#dependencies) - [In-App Purchases](#in-app-purchases) +- [Branch.io Integration] (#branch-integration) - [So Much More](#so-much-more) - [Contributors](#contributors) - [Apps Using OvershareKit](#apps-using-oversharekit) @@ -158,6 +159,16 @@ There are three required external libraries, which are included as git submodule You can optionally configure certain activity types to require in-app purchase. OvershareKit does not handle purchasing or receipt validation, but it does handle the logic around presenting your custom purchasing view controller at the appropriate time. OvershareKit will even badge the activity icons with cute little price tags when they have not yet been purchased. See the header files for `OSKActivitiesManager` and `OSKPurchasingViewController` for more details. +## Branch Integration +Branch.io enables tracking, and personalized downloads for every user of your app through deep links, that pass data **thourgh install and open**. An example use case: Your app has a microblog post the user shares via OvershareKit. Rather than the user sharing the original URL, the Branch integration with OvershareKit automatically converts the original URL into a unique Brach short url for each action. Each short URL auto embeds the sharing channel (facebook, twitter, etc), and extends the OvershareKit Content methods to easily pass in deep link parameters, and tags to track app stage, and specific features. + +The original Branch iOS SDK and Documentation can [be found here](https://github.com/BranchMetrics/Branch-iOS-SDK) + +1. To get started with the Branch integration in OvershareKit, first signup for a [free Branch account](https://branch.io/). +2. Add the Branch API key found in the [Settings panel](https://dashboard.branch.io/#/settings) of the dashboard, to your app's plist file, as "bnc_app_key". Full instructions [found here](https://github.com/BranchMetrics/Branch-iOS-SDK#add-your-app-key-to-your-project). +3. Register a URI scheme in your app's plist file, so your app responds to direct deep links (example: myapp://...). This step is optional, but highly recomended. Full instructions [found here](https://github.com/BranchMetrics/Branch-iOS-SDK#register-a-uri-scheme-direct-deep-linking-optional-but-recommended). +4. Initialize the Branch SDK, and register deep links in the app delegate. (See the sample OvershareKit app for an example). + ## So Much More There’s a ton of stuff to work with in OvershareKit. All of the major and many of the minor classes have been documented with [appledoc](http://gentlebytes.com/appledoc/) syntax. More documentation is coming. If you have questions, please reach out to us. From 11e04aa4953f08d1fdb122c711d783cd842ae9be Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Mon, 26 Jan 2015 09:23:41 -0500 Subject: [PATCH 39/49] Expand init and register deep link steps for Branch --- README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0d3d50a..6786b1a 100644 --- a/README.md +++ b/README.md @@ -162,12 +162,21 @@ You can optionally configure certain activity types to require in-app purchase. ## Branch Integration Branch.io enables tracking, and personalized downloads for every user of your app through deep links, that pass data **thourgh install and open**. An example use case: Your app has a microblog post the user shares via OvershareKit. Rather than the user sharing the original URL, the Branch integration with OvershareKit automatically converts the original URL into a unique Brach short url for each action. Each short URL auto embeds the sharing channel (facebook, twitter, etc), and extends the OvershareKit Content methods to easily pass in deep link parameters, and tags to track app stage, and specific features. +Ideally, you want to use Branch links any time you have an external link pointing to your app (share, invite, referral, etc) because: + +1. The Branch dashboard can tell you where your installs are coming from +2. Branch links are the highest possible converting channel to new downloads and users +3. You can pass shared data across install to give new users a custom welcome or show them the content they expect to see + +Our linking infrastructure will support anything you want to build. If it doesn't, we'll fix it so that it does: just reach out to [alex@branch.io](mailto:alex@branch.io) with requests. + The original Branch iOS SDK and Documentation can [be found here](https://github.com/BranchMetrics/Branch-iOS-SDK) -1. To get started with the Branch integration in OvershareKit, first signup for a [free Branch account](https://branch.io/). -2. Add the Branch API key found in the [Settings panel](https://dashboard.branch.io/#/settings) of the dashboard, to your app's plist file, as "bnc_app_key". Full instructions [found here](https://github.com/BranchMetrics/Branch-iOS-SDK#add-your-app-key-to-your-project). -3. Register a URI scheme in your app's plist file, so your app responds to direct deep links (example: myapp://...). This step is optional, but highly recomended. Full instructions [found here](https://github.com/BranchMetrics/Branch-iOS-SDK#register-a-uri-scheme-direct-deep-linking-optional-but-recommended). -4. Initialize the Branch SDK, and register deep links in the app delegate. (See the sample OvershareKit app for an example). +1. To get started with the Branch integration in OvershareKit, first signup for a [Branch account](https://dashboard.branch.io/) +2. Add the Branch API key found in the [Settings panel](https://dashboard.branch.io/#/settings) of the dashboard, to your app's plist file, as "bnc_app_key". To do this, open the "Info" tab in your XCode project, and add a key to the "Custom iOS Target Properties." +3. Register a URI scheme in your app's plist file, so your app responds to direct deep links (example: myapp://...). This step is optional, but highly recomended. Full instructions [found here](https://github.com/BranchMetrics/Branch-iOS-SDK#register-a-uri-scheme-direct-deep-linking-optional-but-recommended) +4. **Initialize the Branch SDK**. Branch has a singleton instance that can be refferenced by calling [Branch getInstance]. The first time this is called, a singleton is allocated that can be referrenced throughout the app. To initliaize a Branch session, call [[Branch getInstance] initSessionWithLaunchOptions andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) {...}];. There is an example of this in the OvershareKit Sample App. +5. **Register for deeplinks**. You'll likely want your app to respond to it's customer URI scheme, and handle showing the user the correct content with the data your app is passed via the Branch deep link. To do this, your app delegate should respond to - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation. The url passed in via this method, should be sent to the Branch singleton with the method if [[Branch getInstance] handleDeepLink:url]. There is also an example of this in the OvershareKit sample app. ## So Much More From 411297064af7c2b3c91a42a53f4e8f021a07c958 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Mon, 26 Jan 2015 17:02:11 -0500 Subject: [PATCH 40/49] Completes comments and code cleanup --- Overshare Kit/OSKShareableContent.h | 16 ++-- Overshare Kit/OSKShareableContent.m | 81 ++++++++++++------- .../Overshare/Overshare/OSKAppDelegate.m | 13 ++- .../Overshare/SampleTimelineViewController.m | 59 +++++++++++--- 4 files changed, 120 insertions(+), 49 deletions(-) diff --git a/Overshare Kit/OSKShareableContent.h b/Overshare Kit/OSKShareableContent.h index 485bb64..1be6bb8 100644 --- a/Overshare Kit/OSKShareableContent.h +++ b/Overshare Kit/OSKShareableContent.h @@ -138,7 +138,7 @@ These can be custom items, or additional instances of the official items above. @property (copy, nonatomic) NSString *title; -// --- Branch --- +// ========== Branch ========== @property (strong, nonatomic) NSMutableArray *channelsToProcessToBranch; @@ -156,7 +156,7 @@ These can be custom items, or additional instances of the official items above. @property (strong, nonatomic) NSDictionary *branchOGTags; -// --- End Branch --- +// ========== End Branch ========== @end /// ----------------------------------------- @@ -175,7 +175,7 @@ These can be custom items, or additional instances of the official items above. */ + (instancetype)contentFromURL:(NSURL *)url; -// --- Branch --- +// ========== Branch ========== /** Branch extensions to convenient constructors for links */ @@ -257,7 +257,7 @@ These can be custom items, or additional instances of the official items above. + (instancetype)contentFromURL:(NSURL *)url branchFeature:(NSString *)branchFeature; -// --- End Branch --- +// ========== End Branch ========== /** Convenient constructor for content drawn from microblog posts (like Twitter or App.net). @@ -267,7 +267,7 @@ These can be custom items, or additional instances of the official items above. canonicalURL:(NSString *)canonicalURL images:(NSArray *)images; -// --- Branch --- +// ========== Branch ========== /** Branch extensions to convenient constructors for microblog posts */ @@ -394,7 +394,7 @@ These can be custom items, or additional instances of the official items above. images:(NSArray *)images branchFeature:(NSString *)branchFeature; -// --- End Branch --- +// ========== End Branch ========== /** Convenient constructor for sharing one or more images with a common caption. @@ -402,14 +402,14 @@ These can be custom items, or additional instances of the official items above. + (instancetype)contentFromImages:(NSArray *)images caption:(NSString *)caption; -// --- Branch --- +// ========== Branch ========== /** Processes URLs in all Content Items and replaces with Branch URLs */ - (void)processURLsForBranch; -// --- Branch --- +// ========== Branch ========== @end diff --git a/Overshare Kit/OSKShareableContent.m b/Overshare Kit/OSKShareableContent.m index 3399fa4..b97a8ee 100644 --- a/Overshare Kit/OSKShareableContent.m +++ b/Overshare Kit/OSKShareableContent.m @@ -10,7 +10,10 @@ #import "OSKShareableContentItem.h" + +// Include Branch, and Branch preference helper #import "Branch.h" +#import "BNCPreferenceHelper.h" @implementation OSKShareableContent @@ -130,15 +133,24 @@ + (instancetype)contentFromURL:(NSURL *)url textEditing.text = url.absoluteString; content.textEditingItem = textEditing; - // Process all content for Branch URLs - if (url) { + // ========== Branch ========== + // Check to see if a URL is present, and that the Branch API key is present. If so, process all the Content Items for a Branch short URL + if (url && ![[BNCPreferenceHelper getAppKey] isEqualToString:@"bnc_no_value"]) { + + // Branch arguments + content.branchTags = branchTrackingTags; + content.branchStage = branchStage; + content.branchFeature = branchFeature; + content.branchParams = branchParams; + [content initiateBranchWithURL:url]; } + // --- End Branch return content; } -// --- Branch --- +// ========== Branch ========== /** Original class method without Branch arguments @@ -320,7 +332,7 @@ + (instancetype)contentFromURL:(NSURL *)url branchFeature:branchFeature]; }; -// --- End Branch --- +// ========== End Branch ========== + (instancetype)contentFromMicroblogPost:(NSString *)text authorName:(NSString *)authorName @@ -333,12 +345,6 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text OSKShareableContent *content = [[OSKShareableContent alloc] init]; - // Branch arguments - content.branchTags = branchTrackingTags; - content.branchStage = branchStage; - content.branchFeature = branchFeature; - content.branchParams = branchParams; - content.title = [NSString stringWithFormat:@"Post by %@: “%@”", authorName, text]; NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; @@ -441,15 +447,24 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text textEditing.text = emailItem.body; content.textEditingItem = textEditing; - // Process all content for Branch URLs - if (URLforCanonicalURL) { + // ========== Branch ========== + // Check to see if a URL is present, and that the Branch API key is present. If so, process all the Content Items for a Branch short URL + if (URLforCanonicalURL && ![[BNCPreferenceHelper getAppKey] isEqualToString:@"bnc_no_value"]) { + + // Branch arguments + content.branchTags = branchTrackingTags; + content.branchStage = branchStage; + content.branchFeature = branchFeature; + content.branchParams = branchParams; + [content initiateBranchWithURL:URLforCanonicalURL]; } + // --- End Branch return content; } -// --- Branch --- +// ========== Branch ========== /** Original class method without Branch arguments @@ -620,7 +635,7 @@ + (instancetype)contentFromMicroblogPost:(NSString *)text return [OSKShareableContent contentFromMicroblogPost:text authorName:authorName canonicalURL:canonicalURL images:images branchTrackingTags:nil branchParams:nil branchStage:branchStage branchFeature:nil]; }; -//--- End Branch --- +//========== End Branch ========== + (instancetype)contentFromImages:(NSArray *)images caption:(NSString *)caption { OSKShareableContent *content = [[OSKShareableContent alloc] init]; @@ -714,8 +729,10 @@ + (instancetype)contentFromImages:(NSArray *)images caption:(NSString *)caption return content; } -// --- Branch --- +// ========== Branch ========== +// Private calls +// Initates all of the share channels to generate a Branch URL for - (void)initiateBranchWithURL:(NSURL *)url { // Arrays of all channels // Channels that have a url or link attribute @@ -739,14 +756,19 @@ - (void)initiateBranchWithURL:(NSURL *)url { [self processURLsForBranch]; } +// Gets a Branch short URL for each channel +// The Branch SDK cannot generate more then one URL simultaniously, otherwise the callback block will be over written +// To work around this, each channel is stored as an NSString in an NSMutableArray. Once the callback from the first URL is fired, the processed channel is removed from the NSMutable Array. If another NSString is present in the NSMutableArray, processURLsForBranch is called on the OSKShareableContent instance again which processes the next channel in the array - (void)processURLsForBranch { // Sinleton Branch instance Branch *branch = [Branch getInstance]; // Weak block reference to self + // This is so we can reference the self instance from inside the callback block __weak OSKShareableContent *weakContent = self; + //The next channel we're going to process for getShortUrl NSString *channel = [self.channelsToProcessToBranch firstObject]; // Content items that take a single URL as an argument @@ -760,35 +782,38 @@ - (void)processURLsForBranch { __strong OSKShareableContent *strongContent = weakContent; if(!error) { + + // Grab the channel we need to process again NSString *channel = [strongContent.channelsToProcessToBranch firstObject]; + // Each channel type stores the URL in a different property. So we'll make sure we update the correct property here. Once the property is updated with the new URL, the user will be sent to the new Branch URL rather than the original URL if([channel isEqualToString:@"facebook"]) { strongContent.facebookItem.link = [NSURL URLWithString:url]; - NSLog(@"Facebook: %@", strongContent.facebookItem.link); + //NSLog(@"Facebook: %@", strongContent.facebookItem.link); } else if ([channel isEqualToString:@"browser"]) { strongContent.webBrowserItem.url = [NSURL URLWithString:url]; - NSLog(@"Browser: %@", strongContent.webBrowserItem.url); + //NSLog(@"Browser: %@", strongContent.webBrowserItem.url); } else if ([channel isEqualToString:@"read_later"]) { strongContent.readLaterItem.url = [NSURL URLWithString:url]; - NSLog(@"Read Later: %@", strongContent.readLaterItem.url); + //NSLog(@"Read Later: %@", strongContent.readLaterItem.url); } else if ([channel isEqualToString:@"bookmark"]) { strongContent.linkBookmarkItem.url = [NSURL URLWithString:url]; - NSLog(@"Bookmark: %@", strongContent.linkBookmarkItem.url); + //NSLog(@"Bookmark: %@", strongContent.linkBookmarkItem.url); } else if ([channel isEqualToString:@"microblog_twitter"]) { strongContent.microblogPostItem.text = [self branchifiedStringWithURL:url andOriginalString:strongContent.microblogPostItem.text]; - NSLog(@"Twitter / Microblog: %@", strongContent.microblogPostItem.text); + //NSLog(@"Twitter / Microblog: %@", strongContent.microblogPostItem.text); } else if ([channel isEqualToString:@"email"]) { strongContent.emailItem.body = [self branchifiedStringWithURL:url andOriginalString:strongContent.emailItem.body]; - NSLog(@"Email: %@", strongContent.emailItem.body); + //NSLog(@"Email: %@", strongContent.emailItem.body); } else if ([channel isEqualToString:@"sms"]) { strongContent.smsItem.body = [self branchifiedStringWithURL:url andOriginalString:strongContent.smsItem.body]; - NSLog(@"SMS: %@", strongContent.smsItem.body); + //NSLog(@"SMS: %@", strongContent.smsItem.body); } else if ([channel isEqualToString:@"todo"]) { strongContent.toDoListItem.notes = [ self branchifiedStringWithURL:url andOriginalString:strongContent.toDoListItem.notes]; - NSLog(@"Todo: %@", strongContent.toDoListItem.notes); + //NSLog(@"Todo: %@", strongContent.toDoListItem.notes); } else if ([channel isEqualToString:@"text_editor"]) { strongContent.textEditingItem.text = [self branchifiedStringWithURL:url andOriginalString:strongContent.textEditingItem.text]; - NSLog(@"Text editor: %@", strongContent.textEditingItem.text); + //NSLog(@"Text editor: %@", strongContent.textEditingItem.text); } else if ([channel isEqualToString:@"airdrop"]) { NSMutableArray *airdropItems = [strongContent.airDropItem.items mutableCopy]; for (int i = 0; i < [airdropItems count]; i++) { @@ -796,7 +821,7 @@ - (void)processURLsForBranch { airdropItems[i] = [self branchifiedStringWithURL:url andOriginalString:airdropItems[i]]; - NSLog(@"AirDrop: %@", airdropItems[i]); + //NSLog(@"AirDrop: %@", airdropItems[i]); } } strongContent.airDropItem.items = airdropItems; @@ -806,7 +831,7 @@ - (void)processURLsForBranch { // Next channel [strongContent.channelsToProcessToBranch removeObjectAtIndex:0]; if (strongContent.channelsToProcessToBranch.count > 0) { - NSLog(@"\n--------------------------------------\n"); + //NSLog(@"\n--------------------------------------\n"); [strongContent processURLsForBranch]; } }]; @@ -824,7 +849,7 @@ - (NSString *)branchifiedStringWithURL:(NSString *)branchURL andOriginalString:( return [truncatedString stringByAppendingString:branchURL]; } -// identifies all links in a string +// Identifies all links in a string - (NSTextCheckingResult *)identifyAllUrlsAndReplaceInString:(NSString *)string { // Find all URLs in a string NSDataDetector *detect = [[NSDataDetector alloc] initWithTypes:NSTextCheckingTypeLink error:nil]; @@ -834,7 +859,7 @@ - (NSTextCheckingResult *)identifyAllUrlsAndReplaceInString:(NSString *)string { return [allURLs lastObject]; } -// --- End Branch --- +// ========== End Branch ========== - (instancetype)init { self = [super init]; diff --git a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m index 4331ad8..4fbc586 100644 --- a/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m +++ b/Projects/iOS App/Overshare/Overshare/OSKAppDelegate.m @@ -14,7 +14,7 @@ #import "SampleTimelineViewController.h" -// Include Branch, and Branch preference helper +// Include Branch #import "Branch.h" @implementation OSKAppDelegate @@ -42,7 +42,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( For full documentation, see README.md in https://github.com/BranchMetrics/Branch-iOS-SDK */ - // A Pointer to the signleton instance of Branch. The first time this is called in the app lifecycle, a Branch instance is synchronously instatiated. + // Signleton instance of Branch. The first time this is called in the app lifecycle, a Branch instance is synchronously instatiated. Branch *branch = [Branch getInstance]; #ifdef DEBUG @@ -59,6 +59,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( // NSString *name = [params objectForKey:@"user"]; // NSString *profileUrl = [params objectForKey:@"profile_pic"]; // NSString *description = [params objectForKey:@"description"]; + + // --- Setting User Identity with Branch --- + // If you want to track indidvidual users in Branch and/or store reward point baances for referral, pass in a unique user id string here! This method could be implemented a number of ways. You'll most certainly want to implement the setIdentity method on app launch if the user is already logged in, and the ID is stored in the user preferences for example. You will also want to implement this method whent he user signs up or authenticates into your app. + // OvershareKit does have a number of authentication services for Facebook, Twitter, App.net, etc. However, note that each one of these services will return a unique user_id. So if one time the user authenticates in with Twitter, then a different time or on a different device, authenticates with Facebook, they will not be identified as the same user! + [[Branch getInstance] setIdentity:@"your user id"]; } }]; @@ -106,7 +111,7 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl BOOL success = NO; - // --- Branch --- + // ========== Branch ========== // Branch deep link handeler // pass the url to the handle deep link call // if handleDeepLink returns YES, and you registered a callback in initSessionAndRegisterDeepLinkHandler, the callback will be called with the data associated with the deep link. @@ -114,7 +119,7 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl // do other deep link routing for the Facebook SDK, Pinterest SDK, etc } - // --- End Branch --- + // ========== End Branch ========== // OvershareKit deep link routing if ([[OSKADNLoginManager sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation]) { diff --git a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m index 7603d52..f1b9e05 100644 --- a/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m +++ b/Projects/iOS App/Overshare/Overshare/SampleTimelineViewController.m @@ -77,7 +77,8 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { NSString *canonicalURL = @"http://github.com/overshare/overshare-kit"; NSString *authorName = @"testochango"; - // Original method call + // Original OvershareKit Shareable Content Method + // This fork of OvershareKit is 100% backwards compatible, meaning the original shareable content items will still work. If the Branch API key is not present, OvershareKit will behave exactly as it does without Branch: directing the user to the URL that is provided. /* OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text authorName:authorName @@ -85,30 +86,70 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { images:images]; */ - // --- Branch --- + // ========== Branch ========== + // Now let's use Branch!! + // Provided you have set the Branch API key provided to you here: https://dashboard.branch.io/#/settings + // ...the following methods will seamlessly generate OSK shareable content items, and attach a Branch Short URL to each content channel AND automatically tag it with "facebook," "bookmark," etc. for each channel! - // Sets up sample Branch data + // To see this in action, let's setup some dummy data that we'd like to be passed thru download and install of sharing content with another user + + // For a complete explanation of creating Branch links, see: https://github.com/BranchMetrics/Branch-Integration-Guides/blob/master/url-creation-guide.md + + // Branch tags + // ==================================================== + // Accepts an unlimited number of strings in an NSArray. + // This is more a free form entry of anything that + // helps you collect your thoughts. It’s a place where + // you can add meaningful labels for organizing links + // that aren’t confined to a channel or campaign NSArray *branchTags = @[@"test_tag1", @"test_tag2"]; + // Brach deep link params + // ==================================================== + // These are the params you want passed thru the link. + // This could be _anything_ you want: A user id of who shared the content, + // an image URL, an internal URI to direct the user to the content within + // your app, etc. Here are just a few samples... NSMutableDictionary *branchParams = [[NSMutableDictionary alloc] init]; // Example params Deep Link data [branchParams setObject:@"Joe" forKey:@"user"]; [branchParams setObject:@"https://s3-us-west-1.amazonaws.com/myapp/joes_pic.jpg" forKey:@"profile_pic"]; [branchParams setObject:@"Joe likes long walks on the beach..." forKey:@"description"]; - // Example OG params (for social media... http://ogp.me/) + // OpenGraph tags + // ==================================================== + // OpenGraph tags are a way of sharing content attributes + // with social media platforms: http://ogp.me/) <<-- Thanks Facebook! + // These can also be set in the params. A Great thing to do + // If you want your app's name or icon to show up on a Facebook timeline + // when a user shares this on Facebook. [branchParams setObject:@"Joe is a super cool guy!" forKey:@"$og_title"]; [branchParams setObject:@"https://branch.io/img/logo_icon_black.png" forKey:@"$og_image_url"]; [branchParams setObject:@"Because he likes long walks on the beach..." forKey:@"$og_description"]; - // Example Stage + // Branch Stage + // ==================================================== + // This is a label typically used to categorize the progress + // or category of a user when the link was generated. For example, + // if the customer has an invite system accessible on level 1, level 3 and 5, + // the customer could differentiate links generated at each level with this parameter NSString *branchStage = @"test_stage"; - // Example Feature + // Branch Feature + // ==================================================== + // This is the feature of the customer’s product that the + // link might be associated with. For example, if the customer + // had built a referral program in their app, they might have + // tagged all links with the String ‘referral’. NSString *branchFeature = @"test_feature"; - // OSK Content with Branch tags exmaples... - + // OSK Content with Branch params + // ==================================================== + // These methods all return a instance of an OSKShareableContent object + // but they also automatically generate a Branch Short URL with all of the Branch + // params they are provided with! + // you can also call contentFromURL with all of these optional params. + // OSK Content with all arguments OSKShareableContent *content = [OSKShareableContent contentFromMicroblogPost:text authorName:authorName @@ -189,7 +230,7 @@ - (void)showShareSheetForTappedCell:(SampleTimelineCell *)tappedCell { branchFeature:branchFeature]; */ - // --- End Branch --- + // ========== End Branch ========== if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { [self showShareSheet_Phone:content]; From 1a3ba315da7571b9a9d43774e74df405b1cee92e Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Mon, 26 Jan 2015 17:19:55 -0500 Subject: [PATCH 41/49] Adds Branch Links section --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6786b1a..b9a32fc 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ OvershareKit - [URL Schemes](#url-schemes) - [Dependencies](#dependencies) - [In-App Purchases](#in-app-purchases) -- [Branch.io Integration] (#branch-integration) +- [Branch Setup](#branch-setup) +- [Branch Links](#branch-links-in-osk-content) - [So Much More](#so-much-more) - [Contributors](#contributors) - [Apps Using OvershareKit](#apps-using-oversharekit) @@ -159,7 +160,7 @@ There are three required external libraries, which are included as git submodule You can optionally configure certain activity types to require in-app purchase. OvershareKit does not handle purchasing or receipt validation, but it does handle the logic around presenting your custom purchasing view controller at the appropriate time. OvershareKit will even badge the activity icons with cute little price tags when they have not yet been purchased. See the header files for `OSKActivitiesManager` and `OSKPurchasingViewController` for more details. -## Branch Integration +## Branch Setup Branch.io enables tracking, and personalized downloads for every user of your app through deep links, that pass data **thourgh install and open**. An example use case: Your app has a microblog post the user shares via OvershareKit. Rather than the user sharing the original URL, the Branch integration with OvershareKit automatically converts the original URL into a unique Brach short url for each action. Each short URL auto embeds the sharing channel (facebook, twitter, etc), and extends the OvershareKit Content methods to easily pass in deep link parameters, and tags to track app stage, and specific features. Ideally, you want to use Branch links any time you have an external link pointing to your app (share, invite, referral, etc) because: @@ -178,6 +179,8 @@ The original Branch iOS SDK and Documentation can [be found here](https://github 4. **Initialize the Branch SDK**. Branch has a singleton instance that can be refferenced by calling [Branch getInstance]. The first time this is called, a singleton is allocated that can be referrenced throughout the app. To initliaize a Branch session, call [[Branch getInstance] initSessionWithLaunchOptions andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) {...}];. There is an example of this in the OvershareKit Sample App. 5. **Register for deeplinks**. You'll likely want your app to respond to it's customer URI scheme, and handle showing the user the correct content with the data your app is passed via the Branch deep link. To do this, your app delegate should respond to - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation. The url passed in via this method, should be sent to the Branch singleton with the method if [[Branch getInstance] handleDeepLink:url]. There is also an example of this in the OvershareKit sample app. +## Branch Links in OSK Content + ## So Much More There’s a ton of stuff to work with in OvershareKit. All of the major and many of the minor classes have been documented with [appledoc](http://gentlebytes.com/appledoc/) syntax. More documentation is coming. If you have questions, please reach out to us. From 2592c7dca9b33ba46060f4315f11c966a74fe806 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Mon, 26 Jan 2015 17:33:51 -0500 Subject: [PATCH 42/49] Adds README on OSK content Branch extensions --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index b9a32fc..aeca0de 100644 --- a/README.md +++ b/README.md @@ -180,6 +180,40 @@ The original Branch iOS SDK and Documentation can [be found here](https://github 5. **Register for deeplinks**. You'll likely want your app to respond to it's customer URI scheme, and handle showing the user the correct content with the data your app is passed via the Branch deep link. To do this, your app delegate should respond to - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation. The url passed in via this method, should be sent to the Branch singleton with the method if [[Branch getInstance] handleDeepLink:url]. There is also an example of this in the OvershareKit sample app. ## Branch Links in OSK Content +Once you've setup the Branch Integration with the steps in the previous section, you're ready to initiate an OvershareKit Content with Branch short URLs! Normally, you call contentFromMicroblogPost or contentFromURL on an OSKShareableContent instance to setup a collection of Content Items for each share channel (Facebook, Twitter, etc). This integration extends those methods to include the Branch parameters: tracking tags, stage, feature, and deep linking & OG params. An example of this can be seen in the OvershareKit Sample app, in SampleTimelineViewController.m starting at line 82. + +These methods will seamlessly generate OSK shareable content items, and attach a Branch Short URL to each content channel AND automatically tag it with "facebook," "bookmark," etc. for each channel! If you do not have the Branch API key set, OSK will behave as it does without Branch. + +####All availabe Branch OSK extended methods +(All of these methods also available as contentFromMicroblogPost) + +- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary *)branchParams branchStage:(NSString *)branchStage branchFeature:(NSString *)branchFeature + +- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags + +- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary *)branchPrams + +- contentFromURL:(NSURL *)url branchParams:(NSDictionary *)branchPrams + +- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary branchStage:(NSString *)branchStage + +- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchStage:(NSString *)branchStage + +- contentFromURL:(NSURL *)url branchStage:(NSString *)branchStage + +- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary *)branchParams branchFeature:(NSString *)branchFeature + +- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchStage:(NSString *)branchStage branchFeature:(NSString *)branchFeature + +- contentFromURL:(NSURL *)url branchParams:(NSDictionary *)branchParams branchStage:(NSString *)branchStage branchFeature:(NSString *)branchFeature + +- contentFromURL:(NSURL *)url branchParams:(NSDictionary *)branchParams branchFeature:(NSString *)branchFeature + +- contentFromURL:(NSURL *)url branchStage:(NSString *)branchStage branchFeature:(NSString *)branchFeature + +- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchFeature:(NSString *)branchFeature + +- contentFromURL:(NSURL *)url branchFeature:(NSString *)branchFeature ## So Much More From 20b81073f071db119284cd2032605a84df6b8461 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Mon, 26 Jan 2015 17:42:16 -0500 Subject: [PATCH 43/49] Adds directions for setting Branch Identity --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index aeca0de..2da4d95 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ OvershareKit - [In-App Purchases](#in-app-purchases) - [Branch Setup](#branch-setup) - [Branch Links](#branch-links-in-osk-content) +- [Branch Identity](#setting-branch-identity) - [So Much More](#so-much-more) - [Contributors](#contributors) - [Apps Using OvershareKit](#apps-using-oversharekit) @@ -215,6 +216,27 @@ These methods will seamlessly generate OSK shareable content items, and attach - contentFromURL:(NSURL *)url branchFeature:(NSString *)branchFeature +## Setting Branch Identity + +Often, you might have your own user IDs, or want referral and event data to persist across platforms or uninstall/reinstall. It's helpful if you know your users access your service from different devices. This where we introduce the concept of an 'identity'. + +To identify a user, just call: +```objc + [[Branch getInstance] setIdentity:@"your user id"]; +``` +**Note:** +OvershareKit does have a number of authentication services for Facebook, Twitter, App.net, etc. However, each one of these services will return a unique user id. So if one time the user authenticates in with Twitter, then a different time or on a different device, authenticates with Facebook, they will not be identified as the same user! Therefore, you'll need to be sure that you authenticate users on Branch via the same method, or in a way that returns the same user id. + +#### Logout + +If you provide a logout function in your app, be sure to clear the user when the logout completes. This will ensure that all the stored parameters get cleared and all events are properly attributed to the right identity. + +**Warning** this call will clear the referral credits and attribution on the device. + +```objc +[[Branch getInstance] logout]; // previously clearUser +``` + ## So Much More There’s a ton of stuff to work with in OvershareKit. All of the major and many of the minor classes have been documented with [appledoc](http://gentlebytes.com/appledoc/) syntax. More documentation is coming. If you have questions, please reach out to us. From 694fd2c2702549dcadef9053d984a3d8b5d372e2 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Mon, 26 Jan 2015 17:49:49 -0500 Subject: [PATCH 44/49] Cleans up code samples for Branch --- README.md | 52 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 2da4d95..50db682 100644 --- a/README.md +++ b/README.md @@ -176,9 +176,24 @@ The original Branch iOS SDK and Documentation can [be found here](https://github 1. To get started with the Branch integration in OvershareKit, first signup for a [Branch account](https://dashboard.branch.io/) 2. Add the Branch API key found in the [Settings panel](https://dashboard.branch.io/#/settings) of the dashboard, to your app's plist file, as "bnc_app_key". To do this, open the "Info" tab in your XCode project, and add a key to the "Custom iOS Target Properties." + 3. Register a URI scheme in your app's plist file, so your app responds to direct deep links (example: myapp://...). This step is optional, but highly recomended. Full instructions [found here](https://github.com/BranchMetrics/Branch-iOS-SDK#register-a-uri-scheme-direct-deep-linking-optional-but-recommended) -4. **Initialize the Branch SDK**. Branch has a singleton instance that can be refferenced by calling [Branch getInstance]. The first time this is called, a singleton is allocated that can be referrenced throughout the app. To initliaize a Branch session, call [[Branch getInstance] initSessionWithLaunchOptions andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) {...}];. There is an example of this in the OvershareKit Sample App. -5. **Register for deeplinks**. You'll likely want your app to respond to it's customer URI scheme, and handle showing the user the correct content with the data your app is passed via the Branch deep link. To do this, your app delegate should respond to - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation. The url passed in via this method, should be sent to the Branch singleton with the method if [[Branch getInstance] handleDeepLink:url]. There is also an example of this in the OvershareKit sample app. + +4. **Initialize the Branch SDK**. Branch has a singleton instance that can be refferenced by calling [Branch getInstance]. The first time this is called, a singleton is allocated that can be referrenced throughout the app. To initliaize a Branch session, call: +```objc +[[Branch getInstance] initSessionWithLaunchOptions andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) {...}]; +``` +There is an example of this in the OvershareKit Sample App in the app delegate. + +5. **Register for deeplinks**. You'll likely want your app to respond to it's customer URI scheme, and handle showing the user the correct content with the data your app is passed via the Branch deep link. To do this, your app delegate should respond to +```objc +- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; +``` +The url passed in via this method, should be sent to the Branch singleton with: +```objc +[[Branch getInstance] handleDeepLink:url]; +``` +There is also an example of this in the OvershareKit sample app delegate. ## Branch Links in OSK Content Once you've setup the Branch Integration with the steps in the previous section, you're ready to initiate an OvershareKit Content with Branch short URLs! Normally, you call contentFromMicroblogPost or contentFromURL on an OSKShareableContent instance to setup a collection of Content Items for each share channel (Facebook, Twitter, etc). This integration extends those methods to include the Branch parameters: tracking tags, stage, feature, and deep linking & OG params. An example of this can be seen in the OvershareKit Sample app, in SampleTimelineViewController.m starting at line 82. @@ -188,34 +203,35 @@ These methods will seamlessly generate OSK shareable content items, and attach ####All availabe Branch OSK extended methods (All of these methods also available as contentFromMicroblogPost) -- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary *)branchParams branchStage:(NSString *)branchStage branchFeature:(NSString *)branchFeature - -- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags +```objc ++ (instancetype)contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary *)branchParams branchStage:(NSString *)branchStage branchFeature:(NSString *)branchFeature; -- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary *)branchPrams ++ (instancetype)contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags; -- contentFromURL:(NSURL *)url branchParams:(NSDictionary *)branchPrams ++ (instancetype)contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary *)branchPrams; -- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary branchStage:(NSString *)branchStage ++ (instancetype)contentFromURL:(NSURL *)url branchParams:(NSDictionary *)branchPrams; -- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchStage:(NSString *)branchStage ++ (instancetype)contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary branchStage:(NSString *)branchStage; -- contentFromURL:(NSURL *)url branchStage:(NSString *)branchStage ++ (instancetype)contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchStage:(NSString *)branchStage; -- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary *)branchParams branchFeature:(NSString *)branchFeature ++ (instancetype)contentFromURL:(NSURL *)url branchStage:(NSString *)branchStage; -- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchStage:(NSString *)branchStage branchFeature:(NSString *)branchFeature ++ (instancetype)contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchParams:(NSDictionary *)branchParams branchFeature:(NSString *)branchFeature; -- contentFromURL:(NSURL *)url branchParams:(NSDictionary *)branchParams branchStage:(NSString *)branchStage branchFeature:(NSString *)branchFeature ++ (instancetype)contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchStage:(NSString *)branchStage branchFeature:(NSString *)branchFeature; -- contentFromURL:(NSURL *)url branchParams:(NSDictionary *)branchParams branchFeature:(NSString *)branchFeature ++ (instancetype)contentFromURL:(NSURL *)url branchParams:(NSDictionary *)branchParams branchStage:(NSString *)branchStage branchFeature:(NSString *)branchFeature; -- contentFromURL:(NSURL *)url branchStage:(NSString *)branchStage branchFeature:(NSString *)branchFeature ++ (instancetype)contentFromURL:(NSURL *)url branchParams:(NSDictionary *)branchParams branchFeature:(NSString *)branchFeature; -- contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchFeature:(NSString *)branchFeature ++ (instancetype)contentFromURL:(NSURL *)url branchStage:(NSString *)branchStage branchFeature:(NSString *)branchFeature; -- contentFromURL:(NSURL *)url branchFeature:(NSString *)branchFeature ++ (instancetype)contentFromURL:(NSURL *)url branchTrackingTags:(NSArray *)branchTrackingTags branchFeature:(NSString *)branchFeature; ++ (instancetype)contentFromURL:(NSURL *)url branchFeature:(NSString *)branchFeature; +``` ## Setting Branch Identity Often, you might have your own user IDs, or want referral and event data to persist across platforms or uninstall/reinstall. It's helpful if you know your users access your service from different devices. This where we introduce the concept of an 'identity'. @@ -234,7 +250,7 @@ If you provide a logout function in your app, be sure to clear the user when the **Warning** this call will clear the referral credits and attribution on the device. ```objc -[[Branch getInstance] logout]; // previously clearUser +[[Branch getInstance] logout]; ``` ## So Much More From c3c5347eba65a2cc12b25652d504ca51b816c752 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Mon, 26 Jan 2015 17:53:23 -0500 Subject: [PATCH 45/49] Cleans up Branch Setup code examples in Readme --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 50db682..5558a6a 100644 --- a/README.md +++ b/README.md @@ -174,18 +174,19 @@ Our linking infrastructure will support anything you want to build. If it doesn' The original Branch iOS SDK and Documentation can [be found here](https://github.com/BranchMetrics/Branch-iOS-SDK) -1. To get started with the Branch integration in OvershareKit, first signup for a [Branch account](https://dashboard.branch.io/) -2. Add the Branch API key found in the [Settings panel](https://dashboard.branch.io/#/settings) of the dashboard, to your app's plist file, as "bnc_app_key". To do this, open the "Info" tab in your XCode project, and add a key to the "Custom iOS Target Properties." +**To get started** with the Branch integration in OvershareKit, first signup for a [Branch account](https://dashboard.branch.io/) -3. Register a URI scheme in your app's plist file, so your app responds to direct deep links (example: myapp://...). This step is optional, but highly recomended. Full instructions [found here](https://github.com/BranchMetrics/Branch-iOS-SDK#register-a-uri-scheme-direct-deep-linking-optional-but-recommended) +**Add the Branch API key** found in the [Settings panel](https://dashboard.branch.io/#/settings) of the dashboard, to your app's plist file, as "bnc_app_key". To do this, open the "Info" tab in your XCode project, and add a key to the "Custom iOS Target Properties." -4. **Initialize the Branch SDK**. Branch has a singleton instance that can be refferenced by calling [Branch getInstance]. The first time this is called, a singleton is allocated that can be referrenced throughout the app. To initliaize a Branch session, call: +**Register a URI scheme** in your app's plist file, so your app responds to direct deep links (example: myapp://...). This step is optional, but highly recomended. Full instructions [found here](https://github.com/BranchMetrics/Branch-iOS-SDK#register-a-uri-scheme-direct-deep-linking-optional-but-recommended) + +**Initialize the Branch SDK**. Branch has a singleton instance that can be refferenced by calling [Branch getInstance]. The first time this is called, a singleton is allocated that can be referrenced throughout the app. To initliaize a Branch session, call: ```objc [[Branch getInstance] initSessionWithLaunchOptions andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) {...}]; ``` There is an example of this in the OvershareKit Sample App in the app delegate. -5. **Register for deeplinks**. You'll likely want your app to respond to it's customer URI scheme, and handle showing the user the correct content with the data your app is passed via the Branch deep link. To do this, your app delegate should respond to +**Register for deeplinks**. You'll likely want your app to respond to it's customer URI scheme, and handle showing the user the correct content with the data your app is passed via the Branch deep link. To do this, your app delegate should respond to ```objc - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; ``` From e35785735eb406bed020f6a595002d978e9041fc Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Mon, 26 Jan 2015 18:26:19 -0500 Subject: [PATCH 46/49] Implements userCompletedAction --- Overshare Kit/OSKPresentationManager.m | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Overshare Kit/OSKPresentationManager.m b/Overshare Kit/OSKPresentationManager.m index 0858832..2acad5e 100644 --- a/Overshare Kit/OSKPresentationManager.m +++ b/Overshare Kit/OSKPresentationManager.m @@ -37,6 +37,9 @@ #import "UIViewController+OSKUtilities.h" #import "UIColor+OSKUtility.h" +// --- Branch --- +#import "Branch.h" + NSString * const OSKPresentationOption_ActivityCompletionHandler = @"OSKPresentationOption_ActivityCompletionHandler"; NSString * const OSKPresentationOption_PresentationEndingHandler = @"OSKPresentationOption_PresentationEndingHandler"; @@ -374,6 +377,11 @@ - (void)tearDownShadowView { - (void)activitySheet:(OSKActivitySheetViewController *)viewController didSelectActivity:(OSKActivity *)activity { + // --- Branch --- + // Registers that user clicked the share button in the app + Branch *branch = [Branch getInstance]; + [branch userCompletedAction:@"click_share"]; + [self _proceedWithSession:viewController.session selectedActivity:activity presentingViewController:self.presentingViewController @@ -1159,6 +1167,17 @@ - (void)sessionControllerDidBeginPerformingActivity:(OSKSessionController *)cont - (void)sessionControllerDidFinish:(OSKSessionController *)controller successful:(BOOL)successful error:(NSError *)error { + + // --- Branch --- + // Registers if the user was successful or not in sharing + Branch *branch = [Branch getInstance]; + if (successful) { + [branch userCompletedAction:@"successful_share"]; + } else { + [branch userCompletedAction:@"failed_share"]; + } + + OSKSession *session = controller.session; OSKActivity *selectedActivity = controller.activity; @@ -1193,6 +1212,11 @@ - (void)sessionControllerDidCancel:(OSKSessionController *)controller { no need to dismiss it. */ + // --- Branch --- + // Registers that user cancelled the share + Branch *branch = [Branch getInstance]; + [branch userCompletedAction:@"cancelled_share"]; + if ([self isPresenting] == NO) { // Don't perform the presentation ending block unless the activity sheet // has already been dismissed. E.g., on iPad, the session controller From c0d6baaa4a88434a848c1b47ae6c467370434622 Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Mon, 26 Jan 2015 18:37:22 -0500 Subject: [PATCH 47/49] Adds instructions for Branch events --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 5558a6a..2af2e0b 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ OvershareKit - [Branch Setup](#branch-setup) - [Branch Links](#branch-links-in-osk-content) - [Branch Identity](#setting-branch-identity) +- [Branch Events](#branch-events) - [So Much More](#so-much-more) - [Contributors](#contributors) - [Apps Using OvershareKit](#apps-using-oversharekit) @@ -254,6 +255,26 @@ If you provide a logout function in your app, be sure to clear the user when the [[Branch getInstance] logout]; ``` +## Branch Events +The Branch OvershareKit integration automatically registers four events: +- **click_share** registered when a user clicks a share channel option in OvershareKit +- **cancelled_share** registered when a user cancelles sharing a link +- **successful_share** registered when the OvershareKit completion handeler returns with a successful response +- **failed_share** registered when the OvershareKit completion handeler returns with a unseccessful response + +#### Register custom events + +This is very easy to do by calling: +```objc +Branch *branch = [Branch getInstance]; +[branch userCompletedAction:@"your_custom_event"]; +``` +Optionally, you can save the app state with the event: +```objc +Branch *branch = [Branch getInstance]; +[branch userCompletedAction:@"your_custom_event" withState:(NSDictionary *)appState]; +``` + ## So Much More There’s a ton of stuff to work with in OvershareKit. All of the major and many of the minor classes have been documented with [appledoc](http://gentlebytes.com/appledoc/) syntax. More documentation is coming. If you have questions, please reach out to us. From c0e041f556398ac8f5b49f8c5fc5f2a97f319fea Mon Sep 17 00:00:00 2001 From: Scott Hasbrouck Date: Tue, 27 Jan 2015 14:18:27 -0500 Subject: [PATCH 48/49] Updates all submodules --- Dependencies/ADNLogin-SDK | 2 +- Dependencies/Branch-iOS-SDK | 2 +- Dependencies/Pocket-SDK | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dependencies/ADNLogin-SDK b/Dependencies/ADNLogin-SDK index 3c1e043..b2a2c55 160000 --- a/Dependencies/ADNLogin-SDK +++ b/Dependencies/ADNLogin-SDK @@ -1 +1 @@ -Subproject commit 3c1e043b08542e83b3e4f01816650ae4b18c3ddd +Subproject commit b2a2c5574d0ee24a13515c730c5f87b0a0df840f diff --git a/Dependencies/Branch-iOS-SDK b/Dependencies/Branch-iOS-SDK index 9ad7b8f..2b808c3 160000 --- a/Dependencies/Branch-iOS-SDK +++ b/Dependencies/Branch-iOS-SDK @@ -1 +1 @@ -Subproject commit 9ad7b8f0b03e3145c8f451b78ce224df99f3fcb6 +Subproject commit 2b808c34dfa037e20a8b848a0b5bb0f898a60764 diff --git a/Dependencies/Pocket-SDK b/Dependencies/Pocket-SDK index d421134..c161bd8 160000 --- a/Dependencies/Pocket-SDK +++ b/Dependencies/Pocket-SDK @@ -1 +1 @@ -Subproject commit d421134c1b1009148c1e9c9aa35bb42fbfe27e0a +Subproject commit c161bd80711239f8a5a0b5bfeef355204cb8a0e8 From f2eaee7ece1fcf48796b964e6fb0b23c23edfca2 Mon Sep 17 00:00:00 2001 From: Graham Mueller Date: Fri, 8 May 2015 15:46:03 -0500 Subject: [PATCH 49/49] Updating Podspec for fork --- OvershareKit.podspec => OvershareKit+Branch.podspec | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename OvershareKit.podspec => OvershareKit+Branch.podspec (62%) diff --git a/OvershareKit.podspec b/OvershareKit+Branch.podspec similarity index 62% rename from OvershareKit.podspec rename to OvershareKit+Branch.podspec index 542912e..17de22b 100644 --- a/OvershareKit.podspec +++ b/OvershareKit+Branch.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| - s.name = "OvershareKit" - s.version = "1.0.0" - s.summary = "A soup-to-nuts sharing library for iOS." - s.homepage = "https://github.com/overshare/overshare-kit" + s.name = "OvershareKit+Branch" + s.version = "1.3.2" + s.summary = "A soup-to-nuts sharing library for iOS, with a little extra zest from Branch." + s.homepage = "https://github.com/BranchMetrics/overshare-kit" s.license = { :type => 'MIT', :file => 'LICENSE' } - s.author = { "Jared Sinclair" => "desk@jaredsinclair.com", "Justin Williams" => "justin@carpeaqua.com" } - s.source = { :git => "https://github.com/overshare/overshare-kit.git", :tag => s.version.to_s } + s.author = { "Scott Hasbrouck" => "scott@branch.io" } + s.source = { :git => "https://github.com/BranchMetrics/overshare-kit.git", :tag => s.version.to_s } s.platform = :ios, '7.0' s.requires_arc = true s.frameworks = 'UIKit', 'AddressBook', 'CoreMotion', 'CoreLocation', 'MediaPlayer'