Skip to content

Commit c2d5cdd

Browse files
authored
Merge pull request #425 from BranchMetrics/extension_tracking
Tracking iOS extension usage
2 parents 2445e00 + dab1827 commit c2d5cdd

File tree

6 files changed

+9
-13
lines changed

6 files changed

+9
-13
lines changed

Branch-SDK/Branch-SDK/BNCContentDiscoveryManager.m

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,8 @@ - (void)userActivityWillSave:(NSUserActivity *)userActivity {
468468

469469
- (UIViewController *)getActiveViewController {
470470
Class UIApplicationClass = NSClassFromString(@"UIApplication");
471-
if (UIApplicationClass) {
472-
UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
473-
return [self getActiveViewController:rootViewController];
474-
}
475-
476-
return nil;
471+
UIViewController *rootViewController = [UIApplicationClass sharedApplication].keyWindow.rootViewController;
472+
return [self getActiveViewController:rootViewController];
477473
}
478474

479475
- (UIViewController *)getActiveViewController:(UIViewController *)rootViewController {

Branch-SDK/Branch-SDK/BNCServerInterface.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ - (NSDictionary *)prepareParamDict:(NSDictionary *)params key:(NSString *)key re
232232
NSMutableDictionary *fullParamDict = [[NSMutableDictionary alloc] init];
233233
[fullParamDict addEntriesFromDictionary:params];
234234
fullParamDict[@"sdk"] = [NSString stringWithFormat:@"ios%@", SDK_VERSION];
235+
if ([[[NSBundle mainBundle] executablePath] containsString:@".appex/"]) {
236+
fullParamDict[@"ios_extension"] = @(1);
237+
}
235238
fullParamDict[@"retryNumber"] = @(retryNumber);
236239
fullParamDict[@"branch_key"] = key;
237240

Branch-SDK/Branch-SDK/BNCStrongMatchHelper.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ - (void)presentSafariVCWithBranchKey:(NSString *)branchKey {
107107

108108
Class SFSafariViewControllerClass = NSClassFromString(@"SFSafariViewController");
109109
Class UIApplicationClass = NSClassFromString(@"UIApplication");
110-
if (SFSafariViewControllerClass && UIApplicationClass) {
110+
if (SFSafariViewControllerClass) {
111111
NSURL *strongMatchUrl = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
112112
if (!strongMatchUrl) {
113113
self.requestInProgress = NO;

Branch-SDK/Branch-SDK/Branch.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,6 @@ - (BOOL)continueUserActivity:(NSUserActivity *)userActivity {
432432
- (void)handlePushNotification:(NSDictionary *)userInfo {
433433
Class UIApplicationClass = NSClassFromString(@"UIApplication");
434434

435-
if (!UIApplicationClass) { return; }
436-
437435
// If app is active, then close out the session and start a new one
438436
if ([[UIApplicationClass sharedApplication] applicationState] == UIApplicationStateActive) {
439437
[self callClose];
@@ -1265,7 +1263,7 @@ - (void)handleInitSuccess {
12651263
}
12661264

12671265
Class UIApplicationClass = NSClassFromString(@"UIApplication");
1268-
if (self.shouldAutomaticallyDeepLink && UIApplicationClass) {
1266+
if (self.shouldAutomaticallyDeepLink) {
12691267
// Find any matched keys, then launch any controllers that match
12701268
// TODO which one to launch if more than one match?
12711269
NSMutableSet *keysInParams = [NSMutableSet setWithArray:[latestReferringParams allKeys]];

Branch-SDK/Branch-SDK/BranchUniversalObject.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ - (void)showShareSheetWithLinkProperties:(BranchLinkProperties *)linkProperties
200200
}
201201
else {
202202
Class UIApplicationClass = NSClassFromString(@"UIApplication");
203-
if (UIApplicationClass && [[[[UIApplicationClass sharedApplication].delegate window] rootViewController] respondsToSelector:@selector(presentViewController:animated:completion:)]) {
203+
if ([[[[UIApplicationClass sharedApplication].delegate window] rootViewController] respondsToSelector:@selector(presentViewController:animated:completion:)]) {
204204
presentingViewController = [[[UIApplicationClass sharedApplication].delegate window] rootViewController];
205205
}
206206
}

Branch-SDK/Branch-SDK/BranchViewHandler.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ - (BOOL)showBranchView:(NSString *)actionName withBranchViewDictionary:(NSDictio
4444
}
4545

4646
- (BOOL)showBranchView:(BranchView *)branchView withDelegate:(id)callback {
47-
Class UIApplicationClass = NSClassFromString(@"UIApplication");
48-
if (UIApplicationClass && [branchView isAvailable]){
47+
if ([branchView isAvailable]) {
4948
self.branchViewCallback = callback;
5049
[self showView:branchView];
5150
return YES;

0 commit comments

Comments
 (0)