Skip to content

Commit 93794ee

Browse files
authored
Merge pull request #1317 from BranchMetrics/SDK-2051-remove-API-variations-that-confuse-Swift
SDK 2051 remove api variations that confuse swift
2 parents 4029806 + b7ab30a commit 93794ee

File tree

4 files changed

+19
-74
lines changed

4 files changed

+19
-74
lines changed

BranchSDK/BranchShareLink.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ Presents a UIActivityViewController that shares the Branch link.
125125
///The delegate. See 'BranchShareLinkDelegate' above for a description.
126126
@property (nonatomic, weak) id<BranchShareLinkDelegate>_Nullable delegate;
127127

128-
@property void (^ _Nullable completion)(NSString * _Nullable activityType, BOOL completed);
129128
@property void (^ _Nullable completionError)(NSString * _Nullable activityType, BOOL completed, NSError*_Nullable error);
130129

131130
/**

BranchSDK/BranchShareLink.m

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,9 @@ - (void) shareDidComplete:(BOOL)completed activityError:(NSError*)error {
103103
if (completed && !error) {
104104
[[BranchEvent customEventWithName:BNCShareCompletedEvent contentItem:self.universalObject] logEvent];
105105
}
106-
if (self.completion)
107-
self.completion(self.activityType, completed);
108-
else
109-
if (self.completionError)
110-
self.completionError(self.activityType, completed, error);
106+
if (self.completionError) {
107+
self.completionError(self.activityType, completed, error);
108+
}
111109
}
112110

113111
- (NSArray<UIActivityItemProvider*>*_Nonnull) activityItems {
@@ -116,19 +114,14 @@ - (void) shareDidComplete:(BOOL)completed activityError:(NSError*)error {
116114
}
117115

118116
// Make sure we can share
119-
120-
if (!(self.universalObject.canonicalIdentifier ||
121-
self.universalObject.canonicalUrl ||
122-
self.universalObject.title)) {
117+
if (!(self.universalObject.canonicalIdentifier || self.universalObject.canonicalUrl || self.universalObject.title)) {
123118
BNCLogWarning(@"A canonicalIdentifier, canonicalURL, or title are required to uniquely"
124119
" identify content. In order to not break the end user experience with sharing,"
125120
" Branch SDK will proceed to create a URL, but content analytics may not properly"
126121
" include this URL.");
127122
}
128123

129-
self.serverParameters =
130-
[[self.universalObject getParamsForServerRequestWithAddedLinkProperties:self.linkProperties]
131-
mutableCopy];
124+
self.serverParameters = [[self.universalObject getParamsForServerRequestWithAddedLinkProperties:self.linkProperties] mutableCopy];
132125
if (self.linkProperties.matchDuration) {
133126
self.serverParameters[BRANCH_REQUEST_KEY_URL_DURATION] = @(self.linkProperties.matchDuration);
134127
}

BranchSDK/BranchUniversalObject.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -185,34 +185,19 @@ FOUNDATION_EXPORT BranchCondition _Nonnull BranchConditionRefurbished;
185185
#if !TARGET_OS_TV
186186

187187
- (void)showShareSheetWithShareText:(nullable NSString *)shareText
188-
completion:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed))completion;
188+
completion:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed, NSError*_Nullable error))completion;
189189

190-
- (void)showShareSheetWithLinkProperties:(nullable BranchLinkProperties *)linkProperties
191-
andShareText:(nullable NSString *)shareText
192-
fromViewController:(nullable UIViewController *)viewController
193-
completion:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed))completion;
194-
195-
/// Returns with activityError as well
196190
- (void)showShareSheetWithLinkProperties:(nullable BranchLinkProperties *)linkProperties
197191
andShareText:(nullable NSString *)shareText
198192
fromViewController:(nullable UIViewController *)viewController
199193
completionWithError:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed, NSError*_Nullable error))completion;
200194

201-
// iPad
202-
- (void)showShareSheetWithLinkProperties:(nullable BranchLinkProperties *)linkProperties
203-
andShareText:(nullable NSString *)shareText
204-
fromViewController:(nullable UIViewController *)viewController
205-
anchor:(nullable UIBarButtonItem *)anchor
206-
completion:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed))completion;
207-
208-
// Returns with activityError as well
209195
- (void)showShareSheetWithLinkProperties:(nullable BranchLinkProperties *)linkProperties
210196
andShareText:(nullable NSString *)shareText
211197
fromViewController:(nullable UIViewController *)viewController
212198
anchor:(nullable UIBarButtonItem *)anchor
213199
completionWithError:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed, NSError*_Nullable error))completion;
214200

215-
216201
/// @name List items on Spotlight
217202

218203

BranchSDK/BranchUniversalObject.m

Lines changed: 13 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -392,55 +392,26 @@ - (NSString *)getLongUrlWithChannel:(NSString *)channel
392392
#if !TARGET_OS_TV
393393

394394
- (void)showShareSheetWithShareText:(NSString *)shareText
395-
completion:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed))completion {
396-
[self showShareSheetWithLinkProperties:nil andShareText:shareText fromViewController:nil completion:completion];
397-
}
398-
399-
- (void)showShareSheetWithLinkProperties:(BranchLinkProperties *)linkProperties
400-
andShareText:(NSString *)shareText
401-
fromViewController:(UIViewController *)viewController
402-
completion:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed))completion {
403-
[self showShareSheetWithLinkProperties:linkProperties andShareText:shareText
404-
fromViewController:viewController anchor:nil completion:completion orCompletionWithError:nil];
395+
completion:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed, NSError*_Nullable error))completion {
396+
[self showShareSheetWithLinkProperties:nil andShareText:shareText fromViewController:nil completionWithError:completion];
405397
}
406398

407399
- (void)showShareSheetWithLinkProperties:(BranchLinkProperties *)linkProperties
408400
andShareText:(NSString *)shareText
409401
fromViewController:(UIViewController *)viewController
410402
completionWithError:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed, NSError*_Nullable error))completion {
411-
[self showShareSheetWithLinkProperties:linkProperties andShareText:shareText
412-
fromViewController:viewController anchor:nil completion:nil orCompletionWithError:completion];
413-
}
414-
415-
- (void)showShareSheetWithLinkProperties:(nullable BranchLinkProperties *)linkProperties
416-
andShareText:(nullable NSString *)shareText
417-
fromViewController:(nullable UIViewController *)viewController
418-
anchor:(nullable id)anchor
419-
completion:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed))completion {
420-
[self showShareSheetWithLinkProperties:linkProperties andShareText:shareText
421-
fromViewController:viewController anchor:anchor completion:completion orCompletionWithError:nil];
422-
}
423-
424-
- (void)showShareSheetWithLinkProperties:(nullable BranchLinkProperties *)linkProperties
425-
andShareText:(nullable NSString *)shareText
426-
fromViewController:(nullable UIViewController *)viewController
427-
anchor:(nullable id)anchor
428-
completionWithError:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed, NSError*_Nullable error))completion {
429-
[self showShareSheetWithLinkProperties:linkProperties andShareText:shareText
430-
fromViewController:viewController anchor:anchor completion:nil orCompletionWithError:completion];
403+
[self showShareSheetWithLinkProperties:linkProperties andShareText:shareText fromViewController:viewController anchor:nil completionWithError:completion];
431404
}
432405

433406
- (void)showShareSheetWithLinkProperties:(BranchLinkProperties *)linkProperties
434407
andShareText:(NSString *)shareText
435408
fromViewController:(UIViewController *)viewController
436409
anchor:(nullable id)anchorViewOrButtonItem
437-
completion:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed))completion
438-
orCompletionWithError:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed, NSError*_Nullable error))completionError {
410+
completionWithError:(void (^ _Nullable)(NSString * _Nullable activityType, BOOL completed, NSError*_Nullable error))completion {
439411

440412
BranchShareLink *shareLink = [[BranchShareLink alloc] initWithUniversalObject:self linkProperties:linkProperties];
441413
shareLink.shareText = shareText;
442-
shareLink.completion = completion;
443-
shareLink.completionError = completionError;
414+
shareLink.completionError = completion;
444415
[shareLink presentActivityViewControllerFromViewController:viewController anchor:anchorViewOrButtonItem];
445416
}
446417

@@ -464,8 +435,7 @@ - (void)listOnSpotlightWithIdentifierCallback:(callbackWithUrlAndSpotlightIdenti
464435
BOOL publiclyIndexable;
465436
if (self.contentIndexMode == BranchContentIndexModePrivate) {
466437
publiclyIndexable = NO;
467-
}
468-
else {
438+
} else {
469439
publiclyIndexable = YES;
470440
}
471441

@@ -500,17 +470,15 @@ - (void)listOnSpotlightWithLinkProperties:(BranchLinkProperties*_Nullable)linkpr
500470
}];
501471
}
502472

503-
- (void) removeFromSpotlightWithCallback:(void (^_Nullable)(NSError * _Nullable error))completion{
473+
- (void)removeFromSpotlightWithCallback:(void (^_Nullable)(NSError * _Nullable error))completion {
504474
if (self.locallyIndex) {
505-
[[Branch getInstance] removeSearchableItemWithBranchUniversalObject:self
506-
callback:^(NSError *error) {
507-
if (completion) {
508-
completion(error);
509-
}
510-
}];
475+
[[Branch getInstance] removeSearchableItemWithBranchUniversalObject:self callback:^(NSError *error) {
476+
if (completion) {
477+
completion(error);
478+
}
479+
}];
511480
} else {
512-
NSError *error = [NSError branchErrorWithCode:BNCSpotlightPublicIndexError
513-
localizedMessage:@"Publically indexed cannot be removed from Spotlight"];
481+
NSError *error = [NSError branchErrorWithCode:BNCSpotlightPublicIndexError localizedMessage:@"Publically indexed cannot be removed from Spotlight"];
514482
if (completion) completion(error);
515483
}
516484
}

0 commit comments

Comments
 (0)