Skip to content

Commit 2445e00

Browse files
authored
Merge pull request #417 from BranchMetrics/ios-imessage-support
iOS 10 iMessage support for deep linking and BUO
2 parents 9206147 + 74dbe41 commit 2445e00

File tree

16 files changed

+1137
-29
lines changed

16 files changed

+1137
-29
lines changed

Branch-SDK/Branch-SDK/BNCStrongMatchHelper.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ - (void)presentSafariVCWithBranchKey:(NSString *)branchKey {
106106
[urlString appendFormat:@"&sdk=ios%@", SDK_VERSION];
107107

108108
Class SFSafariViewControllerClass = NSClassFromString(@"SFSafariViewController");
109-
if (SFSafariViewControllerClass) {
109+
Class UIApplicationClass = NSClassFromString(@"UIApplication");
110+
if (SFSafariViewControllerClass && UIApplicationClass) {
110111
NSURL *strongMatchUrl = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
111112
if (!strongMatchUrl) {
112113
self.requestInProgress = NO;
@@ -120,7 +121,7 @@ - (void)presentSafariVCWithBranchKey:(NSString *)branchKey {
120121
self.secondWindow.rootViewController = safController;
121122
self.secondWindow.windowLevel = UIWindowLevelNormal - 100;
122123
[self.secondWindow setHidden:NO];
123-
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
124+
UIWindow *keyWindow = [[UIApplicationClass sharedApplication] keyWindow];
124125
[self.secondWindow makeKeyWindow];
125126

126127
// Give enough time for Safari to load the request (optimized for 3G)

Branch-SDK/Branch-SDK/Branch.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
225225
@param alias The alias for a link.
226226
@warning This can fail if the alias is already taken.
227227
*/
228-
+ (BranchActivityItemProvider *)getBranchActivityItemWithParams:(NSDictionary *)params feature:(NSString *)feature stage:(NSString *)stage campaign:(NSString *)campmaign tags:(NSArray *)tags alias:(NSString *)alias;
228+
+ (BranchActivityItemProvider *)getBranchActivityItemWithParams:(NSDictionary *)params feature:(NSString *)feature stage:(NSString *)stage campaign:(NSString *)campaign tags:(NSArray *)tags alias:(NSString *)alias;
229229

230230
/**
231231
Create a BranchActivityItemProvider which subclasses the `UIActivityItemProvider` This can be used for simple sharing via a `UIActivityViewController`.
@@ -388,14 +388,14 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
388388
/**
389389
Add a scheme to a whitelist of URI schemes that will be tracked by Branch. Default to all schemes.
390390
391-
@param the scheme to add to the whitelist, i.e. @"http", @"https" or @"myapp"
391+
@param scheme to add to the whitelist, i.e. @"http", @"https" or @"myapp"
392392
*/
393393
-(void)addWhiteListedScheme:(NSString *)scheme;
394394

395395
/**
396396
Add an array of schemes to a whitelist of URI schemes that will be tracked by Branch. Default to all schemes.
397397
398-
@param the array of schemes to add to the whitelist, i.e. @[@"http", @"https", @"myapp"]
398+
@param schemes array to add to the whitelist, i.e. @[@"http", @"https", @"myapp"]
399399
*/
400400
-(void)setWhiteListedSchemes:(NSArray *)schemes;
401401

@@ -739,7 +739,7 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
739739
@param channel The channel for the link. Examples could be Facebook, Twitter, SMS, etc, depending on where it will be shared.
740740
@param feature The feature this is utilizing. Examples could be Sharing, Referring, Inviting, etc.
741741
@param stage The stage used for the generated link, indicating what part of a funnel the user is in.
742-
@param matchDuration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
742+
@param duration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
743743
@warning This method makes a synchronous url request.
744744
*/
745745
- (NSString *)getShortURLWithParams:(NSDictionary *)params andChannel:(NSString *)channel andFeature:(NSString *)feature andStage:(NSString *)stage andMatchDuration:(NSUInteger)duration;
@@ -825,7 +825,7 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
825825
@param channel The channel for the link. Examples could be Facebook, Twitter, SMS, etc, depending on where it will be shared.
826826
@param feature The feature this is utilizing. Examples could be Sharing, Referring, Inviting, etc.
827827
@param stage The stage used for the generated link, indicating what part of a funnel the user is in.
828-
@param matchDuration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
828+
@param duration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
829829
@warning This method makes a synchronous url request.
830830
*/
831831
- (NSString *)getShortURLWithParams:(NSDictionary *)params andTags:(NSArray *)tags andChannel:(NSString *)channel andFeature:(NSString *)feature andStage:(NSString *)stage andMatchDuration:(NSUInteger)duration;
@@ -839,7 +839,7 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
839839
@param channel The channel for the link. Examples could be Facebook, Twitter, SMS, etc, depending on where it will be shared.
840840
@param feature The feature this is utilizing. Examples could be Sharing, Referring, Inviting, etc.
841841
@param stage The stage used for the generated link, indicating what part of a funnel the user is in.
842-
@param matchDuration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
842+
@param duration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
843843
@warning This method makes a synchronous url request.
844844
@warning This can fail if the alias is already taken.
845845
*/
@@ -856,7 +856,7 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
856856
@param feature The feature this is utilizing. Examples could be Sharing, Referring, Inviting, etc.
857857
@param stage The stage used for the generated link, indicating what part of a funnel the user is in.
858858
@param campaign Use this field to organize the links by actual marketing campaign.
859-
@param matchDuration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
859+
@param duration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
860860
@warning This method makes a synchronous url request.
861861
*/
862862
- (NSString *)getShortUrlWithParams:(NSDictionary *)params andTags:(NSArray *)tags andAlias:(NSString *)alias andChannel:(NSString *)channel andFeature:(NSString *)feature andStage:(NSString *)stage andCampaign:campaign andMatchDuration:(NSUInteger)duration;
@@ -999,7 +999,7 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
999999
@param channel The channel for the link. Examples could be Facebook, Twitter, SMS, etc, depending on where it will be shared.
10001000
@param feature The feature this is utilizing. Examples could be Sharing, Referring, Inviting, etc.
10011001
@param stage The stage used for the generated link, indicating what part of a funnel the user is in.
1002-
@param matchDuration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
1002+
@param duration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
10031003
@param callback Callback called with the url.
10041004
*/
10051005
- (void)getShortURLWithParams:(NSDictionary *)params andChannel:(NSString *)channel andFeature:(NSString *)feature andStage:(NSString *)stage andMatchDuration:(NSUInteger)duration andCallback:(callbackWithUrl)callback;
@@ -1051,7 +1051,7 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
10511051
@param tags An array of tags to associate with this link, useful for tracking.
10521052
@param feature The feature this is utilizing. Examples could be Sharing, Referring, Inviting, etc.
10531053
@param stage The stage used for the generated link, indicating what part of a funnel the user is in.
1054-
@param matchDuration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
1054+
@param duration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
10551055
@param callback Callback called with the url.
10561056
*/
10571057
- (void)getShortURLWithParams:(NSDictionary *)params andTags:(NSArray *)tags andChannel:(NSString *)channel andFeature:(NSString *)feature andStage:(NSString *)stage andMatchDuration:(NSUInteger)duration andCallback:(callbackWithUrl)callback;
@@ -1064,7 +1064,7 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
10641064
@param tags An array of tags to associate with this link, useful for tracking.
10651065
@param feature The feature this is utilizing. Examples could be Sharing, Referring, Inviting, etc.
10661066
@param stage The stage used for the generated link, indicating what part of a funnel the user is in.
1067-
@param matchDuration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
1067+
@param duration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
10681068
@param callback Callback called with the url.
10691069
@param alias The alias for a link.
10701070
@warning This can fail if the alias is already taken.
@@ -1079,7 +1079,7 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
10791079
@param tags An array of tags to associate with this link, useful for tracking.
10801080
@param feature The feature this is utilizing. Examples could be Sharing, Referring, Inviting, etc.
10811081
@param stage The stage used for the generated link, indicating what part of a funnel the user is in.
1082-
@param matchDuration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
1082+
@param duration How long to keep an unmatched link click in the Branch backend server's queue before discarding.
10831083
@param campaign Use this field to organize the links by actual marketing campaign.
10841084
@param callback Callback called with the url.
10851085
@param alias The alias for a link.
@@ -1210,9 +1210,8 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
12101210
@param title Title for the spotlight preview item.
12111211
@param description Description for the spotlight preview item.
12121212
@param thumbnailUrl Url to an image to be used for the thumnbail in spotlight.
1213-
@param type The type to use for the NSUserActivity, taken from the list of constants provided in the MobileCoreServices framework.
12141213
@param publiclyIndexable Whether or not this item should be added to Apple's public search index.
1215-
@param keywords A set of keywords to be used in Apple's search index.
1214+
@param linkParams A set of keywords to be used in Apple's search index.
12161215
@warning These functions are only usable on iOS 9 or above. Earlier versions will simply receive the callback with an error.
12171216
*/
12181217
- (void)createDiscoverableContentWithTitle:(NSString *)title description:(NSString *)description thumbnailUrl:(NSURL *)thumbnailUrl linkParams:(NSDictionary *)linkParams publiclyIndexable:(BOOL)publiclyIndexable;
@@ -1259,7 +1258,7 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
12591258
@param type The type to use for the NSUserActivity, taken from the list of constants provided in the MobileCoreServices framework.
12601259
@param keywords A set of keywords to be used in Apple's search index.
12611260
@param expirationDate ExpirationDate after which this will not appear in Apple's search index.
1262-
@param callback Callback called with the Branch url this will fallback to.
1261+
@param spotlightCallback Callback called with the Branch url this will fallback to.
12631262
@warning These functions are only usable on iOS 9 or above. Earlier versions will simply receive the callback with an error.
12641263
*/
12651264
- (void)createDiscoverableContentWithTitle:(NSString *)title description:(NSString *)description thumbnailUrl:(NSURL *)thumbnailUrl linkParams:(NSDictionary *)linkParams type:(NSString *)type publiclyIndexable:(BOOL)publiclyIndexable keywords:(NSSet *)keywords expirationDate:(NSDate *)expirationDate spotlightCallback:(callbackWithUrlAndSpotlightIdentifier)spotlightCallback;

Branch-SDK/Branch-SDK/Branch.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,13 @@ - (BOOL)continueUserActivity:(NSUserActivity *)userActivity {
429429
#pragma mark - Push Notification support
430430

431431
// handle push notification if app is already launched
432-
- (void)handlePushNotification:(NSDictionary *) userInfo {
432+
- (void)handlePushNotification:(NSDictionary *)userInfo {
433+
Class UIApplicationClass = NSClassFromString(@"UIApplication");
434+
435+
if (!UIApplicationClass) { return; }
436+
433437
// If app is active, then close out the session and start a new one
434-
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive) {
438+
if ([[UIApplicationClass sharedApplication] applicationState] == UIApplicationStateActive) {
435439
[self callClose];
436440
}
437441

@@ -443,7 +447,7 @@ - (void)handlePushNotification:(NSDictionary *) userInfo {
443447
}
444448

445449
// Again, if app is active, then close out the session and start a new one
446-
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive) {
450+
if ([[UIApplicationClass sharedApplication] applicationState] == UIApplicationStateActive) {
447451
[self applicationDidBecomeActive];
448452
}
449453
}
@@ -1260,7 +1264,8 @@ - (void)handleInitSuccess {
12601264
}
12611265
}
12621266

1263-
if (self.shouldAutomaticallyDeepLink) {
1267+
Class UIApplicationClass = NSClassFromString(@"UIApplication");
1268+
if (self.shouldAutomaticallyDeepLink && UIApplicationClass) {
12641269
// Find any matched keys, then launch any controllers that match
12651270
// TODO which one to launch if more than one match?
12661271
NSMutableSet *keysInParams = [NSMutableSet setWithArray:[latestReferringParams allKeys]];
@@ -1278,7 +1283,7 @@ - (void)handleInitSuccess {
12781283
[self.preferenceHelper log:FILE_NAME line:LINE_NUM message:@"[Branch Warning] View controller does not implement configureControlWithData:"];
12791284
}
12801285
branchSharingController.deepLinkingCompletionDelegate = self;
1281-
self.deepLinkPresentingController = [[[UIApplication sharedApplication].delegate window] rootViewController];
1286+
self.deepLinkPresentingController = [[[UIApplicationClass sharedApplication].delegate window] rootViewController];
12821287

12831288
if ([self.deepLinkPresentingController presentedViewController]) {
12841289
[self.deepLinkPresentingController dismissViewControllerAnimated:NO completion:^{

Branch-SDK/Branch-SDK/BranchUniversalObject.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,11 @@ - (void)showShareSheetWithLinkProperties:(BranchLinkProperties *)linkProperties
198198
if (viewController && [viewController respondsToSelector:@selector(presentViewController:animated:completion:)]) {
199199
presentingViewController = viewController;
200200
}
201-
else if ([[[[UIApplication sharedApplication].delegate window] rootViewController] respondsToSelector:@selector(presentViewController:animated:completion:)]) {
202-
presentingViewController = [[[UIApplication sharedApplication].delegate window] rootViewController];
201+
else {
202+
Class UIApplicationClass = NSClassFromString(@"UIApplication");
203+
if (UIApplicationClass && [[[[UIApplicationClass sharedApplication].delegate window] rootViewController] respondsToSelector:@selector(presentViewController:animated:completion:)]) {
204+
presentingViewController = [[[UIApplicationClass sharedApplication].delegate window] rootViewController];
205+
}
203206
}
204207

205208
if (linkProperties.controlParams[BRANCH_LINK_DATA_KEY_EMAIL_SUBJECT]) {

Branch-SDK/Branch-SDK/BranchViewHandler.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ + (BranchViewHandler *)getInstance {
4040

4141
- (BOOL)showBranchView:(NSString *)actionName withBranchViewDictionary:(NSDictionary*)branchViewDict andWithDelegate:(id)callback {
4242
BranchView *branchView = [[BranchView alloc] initWithBranchView:branchViewDict andActionName:actionName];
43-
return[self showBranchView:branchView withDelegate:callback];
43+
return [self showBranchView:branchView withDelegate:callback];
4444
}
4545

4646
- (BOOL)showBranchView:(BranchView *)branchView withDelegate:(id)callback {
47-
if ([branchView isAvailable]){
47+
Class UIApplicationClass = NSClassFromString(@"UIApplication");
48+
if (UIApplicationClass && [branchView isAvailable]){
4849
self.branchViewCallback = callback;
4950
[self showView:branchView];
5051
return YES;
@@ -87,7 +88,8 @@ - (void)showView:(BranchView *)branchView {
8788
}
8889

8990
- (void)closeBranchView {
90-
UIViewController *presentingViewController = [[[[UIApplication sharedApplication] windows] firstObject] rootViewController];
91+
Class UIApplicationClass = NSClassFromString(@"UIApplication");
92+
UIViewController *presentingViewController = [[[[UIApplicationClass sharedApplication] windows] firstObject] rootViewController];
9193
[presentingViewController dismissViewControllerAnimated:YES completion:nil];
9294

9395
if (self.branchViewCallback) {
@@ -115,7 +117,8 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView {
115117
if (self.pendingBranchView != nil && self.pendingWebview != nil) {
116118
UIViewController *holderView = [[UIViewController alloc] init];
117119
[holderView.view insertSubview:self.pendingWebview atIndex:0];
118-
UIViewController *presentingViewController = [[[[UIApplication sharedApplication] windows] firstObject] rootViewController];
120+
Class UIApplicationClass = NSClassFromString(@"UIApplication");
121+
UIViewController *presentingViewController = [[[[UIApplicationClass sharedApplication] windows] firstObject] rootViewController];
119122
[presentingViewController presentViewController:holderView animated:YES completion:nil];
120123

121124
[self.pendingBranchView updateUsageCount];
@@ -149,4 +152,4 @@ - (BOOL)handleUserActionRedirects:(NSURLRequest *)request {
149152
}
150153

151154

152-
@end
155+
@end

Branch-SDK/Fabric/Fabric.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
4040
*
4141
* Only the first call to this method is honored. Subsequent calls are no-ops.
4242
*
43-
* @param kits An array of kit Class objects
43+
* @param kitClasses An array of kit Class objects
4444
*
4545
* @return Returns the shared Fabric instance. In most cases this can be ignored.
4646
*/

0 commit comments

Comments
 (0)