Skip to content

Commit 053d075

Browse files
committed
CORE-2088 add willShowPasteboardToast method
1 parent ccc8ecf commit 053d075

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
lines changed

Branch-SDK/BNCPasteboard.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ NS_ASSUME_NONNULL_BEGIN
1212

1313
@interface BNCPasteboard : NSObject
1414

15-
// For v1, we only allow check on install requests
15+
// For v1, we only allow check on install requests. By default, this is NO
1616
@property (nonatomic,assign) BOOL checkOnInstall;
1717

18+
@property (nonatomic, assign, nullable) NSURL *branchLink;
19+
20+
- (BOOL)isUrlOnPasteboard;
21+
1822
- (nullable NSURL *)checkForBranchLink;
1923

2024
+ (BNCPasteboard *)sharedInstance;

Branch-SDK/BNCPasteboard.m

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,26 @@ - (instancetype)init {
2929
return self;
3030
}
3131

32-
- (nullable NSURL *)checkForBranchLink {
33-
32+
- (BOOL)isUrlOnPasteboard {
3433
#if !TARGET_OS_TV
3534
if (@available(iOS 10.0, *)) {
3635
if ([UIPasteboard.generalPasteboard hasURLs]) {
37-
38-
// triggers the end user toast message
39-
NSURL *tmp = UIPasteboard.generalPasteboard.URL;
40-
if ([Branch isBranchLink:tmp.absoluteString]) {
41-
return tmp;
42-
}
36+
return YES;
4337
}
4438
}
4539
#endif
40+
return NO;
41+
}
42+
43+
- (nullable NSURL *)checkForBranchLink {
44+
if ([self isUrlOnPasteboard]) {
45+
// triggers the end user toast message
46+
NSURL *tmp = UIPasteboard.generalPasteboard.URL;
47+
if ([Branch isBranchLink:tmp.absoluteString]) {
48+
self.branchLink = tmp;
49+
return tmp;
50+
}
51+
}
4652
return nil;
4753
}
4854

Branch-SDK/Branch.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,16 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
684684
*/
685685
- (void)checkPasteboardOnInstall;
686686

687+
/**
688+
Let's client know if the Branch SDK will trigger a pasteboard toast to the end user.
689+
All of the following conditions must be true.
690+
691+
1. Developer called checkPastboardOnInstall before initSession
692+
2. A URL is on the pasteboard
693+
3. First time app is run with Branch SDK
694+
*/
695+
- (BOOL)willShowPasteboardToast;
696+
687697
/**
688698
Set the AppGroup used to share data between the App Clip and the Full App.
689699

Branch-SDK/Branch.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,15 @@ - (void)checkPasteboardOnInstall {
949949
[BNCPasteboard sharedInstance].checkOnInstall = YES;
950950
}
951951

952+
- (BOOL)willShowPasteboardToast {
953+
if (!self.preferenceHelper.identityID &&
954+
[BNCPasteboard sharedInstance].checkOnInstall &&
955+
[BNCPasteboard sharedInstance].isUrlOnPasteboard) {
956+
return YES;
957+
}
958+
return NO;
959+
}
960+
952961
- (void)checkAppleSearchAdsAttribution {
953962
#if !TARGET_OS_TV
954963
if (![BNCAppleSearchAds sharedInstance].enableAppleSearchAdsCheck) {

0 commit comments

Comments
 (0)