Skip to content

Commit e235ec8

Browse files
committed
Release 1.44.0
- SDK-1658 Added Support for VIEW_AD, INITIATE_STREAM, COMPLETE_STREAM and all V2 Events as Standard events - SDK-1480 [iOS 16] Added UIPaste Support for NativeLink Flow
1 parent 2a430f2 commit e235ec8

29 files changed

+573
-88
lines changed

Branch-SDK/BNCConfig.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
NSString * const BNC_API_BASE_URL = @"https://api2.branch.io";
1212
NSString * const BNC_API_VERSION = @"v1";
1313
NSString * const BNC_LINK_URL = @"https://bnc.lt";
14-
NSString * const BNC_SDK_VERSION = @"1.43.2";
14+
NSString * const BNC_SDK_VERSION = @"1.44.0";

Branch-SDK/BNCPreferenceHelper.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ NSURL* /* _Nonnull */ BNCURLForBranchDirectory(void);
2929
@property (copy, nonatomic) NSString *sessionID;
3030
@property (copy, nonatomic) NSString *linkClickIdentifier;
3131
@property (copy, nonatomic) NSString *spotlightIdentifier;
32-
@property (copy, nonatomic) NSString *universalLinkUrl;
33-
@property (copy, nonatomic) NSString *initialReferrer;
32+
@property (copy, nonatomic) NSString *universalLinkUrl;
33+
@property (copy, nonatomic) NSString *initialReferrer;
3434
@property (copy, nonatomic) NSString *userUrl;
35+
@property (copy, nonatomic) NSString *localUrl;
3536
@property (copy, nonatomic) NSString *userIdentity;
3637
@property (copy, nonatomic) NSString *sessionParams;
3738
@property (copy, nonatomic) NSString *installParams;

Branch-SDK/BNCPreferenceHelper.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
static NSString * const BRANCH_PREFS_KEY_LINK_CLICK_IDENTIFIER = @"bnc_link_click_identifier";
3737
static NSString * const BRANCH_PREFS_KEY_SPOTLIGHT_IDENTIFIER = @"bnc_spotlight_identifier";
3838
static NSString * const BRANCH_PREFS_KEY_UNIVERSAL_LINK_URL = @"bnc_universal_link_url";
39+
static NSString * const BRANCH_PREFS_KEY_LOCAL_URL = @"bnc_local_url";
3940
static NSString * const BRANCH_PREFS_KEY_INITIAL_REFERRER = @"bnc_initial_referrer";
4041
static NSString * const BRANCH_PREFS_KEY_SESSION_PARAMS = @"bnc_session_params";
4142
static NSString * const BRANCH_PREFS_KEY_INSTALL_PARAMS = @"bnc_install_params";
@@ -80,6 +81,7 @@ @implementation BNCPreferenceHelper
8081
installParams = _installParams,
8182
universalLinkUrl = _universalLinkUrl,
8283
initialReferrer = _initialReferrer,
84+
localUrl = _localUrl,
8385
externalIntentURI = _externalIntentURI,
8486
isDebug = _isDebug,
8587
retryCount = _retryCount,
@@ -325,6 +327,14 @@ - (void)setUniversalLinkUrl:(NSString *)universalLinkUrl {
325327
[self writeObjectToDefaults:BRANCH_PREFS_KEY_UNIVERSAL_LINK_URL value:universalLinkUrl];
326328
}
327329

330+
- (NSString *)localUrl {
331+
return [self readStringFromDefaults:BRANCH_PREFS_KEY_LOCAL_URL];
332+
}
333+
334+
- (void)setLocalUrl:(NSString *)localURL {
335+
[self writeObjectToDefaults:BRANCH_PREFS_KEY_LOCAL_URL value:localURL];
336+
}
337+
328338
- (NSString *)initialReferrer {
329339
return [self readStringFromDefaults:BRANCH_REQUEST_KEY_INITIAL_REFERRER];
330340
}

Branch-SDK/Branch.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
@import Foundation;
1111
#else
1212
#import <Foundation/Foundation.h>
13+
#import <UniformTypeIdentifiers/UniformTypeIdentifiers.h>
1314
#endif
1415

1516
#import "BNCCallbacks.h"
@@ -1838,6 +1839,16 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
18381839
// Read-only property exposed for unit testing.
18391840
@property (strong, readonly) BNCServerInterface* serverInterface;
18401841
- (void) clearNetworkQueue;
1842+
1843+
#if !TARGET_OS_TV
1844+
#pragma mark - UIPasteControl Support
1845+
/**
1846+
This method is used to pass paste board items to Branch SDK when user implements UIPasteControl at their end. SDK retrives URL from these item providers if any to support native link functionality.
1847+
@param itemProviders - an array of item providers collected from pasteboard.
1848+
@warning This function works with iOS 16 or above.
1849+
*/
1850+
- (void)passPasteItemProviders:(NSArray<NSItemProvider *> *)itemProviders API_AVAILABLE(ios(16));
1851+
#endif
18411852
@end
18421853

18431854
NS_ASSUME_NONNULL_END

Branch-SDK/Branch.m

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,30 @@ - (void)removeAllPrivateContentFromSpotLightWithCallback:(void (^)(NSError * err
15921592
}
15931593
#endif
15941594

1595+
#if !TARGET_OS_TV
1596+
#pragma mark - UIPasteControl Support methods
1597+
1598+
- (void)passPasteItemProviders:(NSArray<NSItemProvider *> *)itemProviders {
1599+
1600+
// 1. Extract URL from NSItemProvider arrary
1601+
for (NSItemProvider* item in itemProviders){
1602+
if ( [item hasItemConformingToTypeIdentifier: UTTypeURL.identifier] ) {
1603+
// 2. Check if URL is branch URL and if yes -> store it.
1604+
[item loadItemForTypeIdentifier:UTTypeURL.identifier options:NULL completionHandler:^(NSURL *url, NSError * _Null_unspecified error) {
1605+
if (error) {
1606+
BNCLogError([NSString stringWithFormat:@"%@", error]);
1607+
}
1608+
else if ([Branch isBranchLink:url.absoluteString]) {
1609+
[self.preferenceHelper setLocalUrl:[url absoluteString]];
1610+
// 3. Send Open Event
1611+
[[Branch getInstance] handleDeepLink:url];
1612+
}
1613+
}];
1614+
}
1615+
}
1616+
}
1617+
#endif
1618+
15951619
#pragma mark - Private methods
15961620

15971621
+ (Branch *)getInstanceInternal:(NSString *)key {
@@ -2124,7 +2148,6 @@ - (void)initUserSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSStr
21242148

21252149
// callback on main, this is generally what the client expects and maintains our previous behavior
21262150
dispatch_async(dispatch_get_main_queue(), ^ {
2127-
21282151
if (self.sceneSessionInitWithCallback) {
21292152
BNCInitSessionResponse *response = [BNCInitSessionResponse new];
21302153
response.params = [self getLatestReferringParams];

Branch-SDK/BranchEvent.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ FOUNDATION_EXPORT BranchStandardEvent _Nonnull BranchStandardEventViewItem;
3535
FOUNDATION_EXPORT BranchStandardEvent _Nonnull BranchStandardEventViewItems;
3636
FOUNDATION_EXPORT BranchStandardEvent _Nonnull BranchStandardEventRate;
3737
FOUNDATION_EXPORT BranchStandardEvent _Nonnull BranchStandardEventShare;
38+
FOUNDATION_EXPORT BranchStandardEvent _Nonnull BranchStandardEventInitiateStream;
39+
FOUNDATION_EXPORT BranchStandardEvent _Nonnull BranchStandardEventCompleteStream;
40+
3841

3942
///@name User Lifecycle Events
4043

Branch-SDK/BranchEvent.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
BranchStandardEvent BranchStandardEventViewItems = @"VIEW_ITEMS";
3737
BranchStandardEvent BranchStandardEventRate = @"RATE";
3838
BranchStandardEvent BranchStandardEventShare = @"SHARE";
39+
BranchStandardEvent BranchStandardEventInitiateStream = @"INITIATE_STREAM";
40+
BranchStandardEvent BranchStandardEventCompleteStream = @"COMPLETE_STREAM";
3941

4042
// User Lifecycle Events
4143

@@ -245,6 +247,8 @@ - (NSDictionary*) dictionary {
245247
BranchStandardEventViewAd,
246248
BranchStandardEventOptOut,
247249
BranchStandardEventOptIn,
250+
BranchStandardEventInitiateStream,
251+
BranchStandardEventCompleteStream
248252
];
249253
}
250254

Branch-SDK/BranchInstallRequest.m

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ - (id)initWithCallback:(callbackWithStatus)callback {
2626
- (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key callback:(BNCServerCallback)callback {
2727
BNCPreferenceHelper *preferenceHelper = [BNCPreferenceHelper sharedInstance];
2828
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
29+
super.clearLocalURL = FALSE;
2930

3031
[self safeSetValue:[BNCSystemObserver getBundleID] forKey:BRANCH_REQUEST_KEY_BUNDLE_ID onDict:params];
3132
[self safeSetValue:[BNCSystemObserver getTeamIdentifier] forKey:BRANCH_REQUEST_KEY_TEAM_ID onDict:params];
@@ -69,7 +70,19 @@ - (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key ca
6970
}
7071

7172
if ([BNCPasteboard sharedInstance].checkOnInstall) {
72-
NSURL *pasteboardURL = [[BNCPasteboard sharedInstance] checkForBranchLink];
73+
NSURL *pasteboardURL = nil;
74+
if (@available(iOS 16.0, *)) {
75+
NSString *localURLString = [[BNCPreferenceHelper sharedInstance] localUrl];
76+
if(localURLString){
77+
pasteboardURL = [[NSURL alloc] initWithString:localURLString];
78+
super.clearLocalURL = TRUE;
79+
} else {
80+
pasteboardURL = [[BNCPasteboard sharedInstance] checkForBranchLink];
81+
}
82+
} else {
83+
pasteboardURL = [[BNCPasteboard sharedInstance] checkForBranchLink];
84+
}
85+
7386
if (pasteboardURL) {
7487
[self safeSetValue:pasteboardURL.absoluteString forKey:BRANCH_REQUEST_KEY_LOCAL_URL onDict:params];
7588
}

Branch-SDK/BranchOpenRequest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
@interface BranchOpenRequest : BNCServerRequest
1313

1414
@property (nonatomic, copy) callbackWithStatus callback;
15+
@property (assign, nonatomic) BOOL clearLocalURL;
1516

1617
+ (void) waitForOpenResponseLock;
1718
+ (void) releaseOpenResponseLock;

Branch-SDK/BranchOpenRequest.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ - (id)initWithCallback:(callbackWithStatus)callback isInstall:(BOOL)isInstall {
4343
}
4444

4545
- (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key callback:(BNCServerCallback)callback {
46+
self.clearLocalURL = FALSE;
4647
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
4748

4849
BNCPreferenceHelper *preferenceHelper = [BNCPreferenceHelper sharedInstance];
@@ -100,6 +101,17 @@ - (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key ca
100101
if (partnerParameters.count > 0) {
101102
[self safeSetValue:partnerParameters forKey:BRANCH_REQUEST_KEY_PARTNER_PARAMETERS onDict:params];
102103
}
104+
105+
if (@available(iOS 16.0, *)) {
106+
NSString *localURLString = [[BNCPreferenceHelper sharedInstance] localUrl];
107+
if(localURLString){
108+
NSURL *localURL = [[NSURL alloc] initWithString:localURLString];
109+
if (localURL) {
110+
[self safeSetValue:localURL.absoluteString forKey:BRANCH_REQUEST_KEY_LOCAL_URL onDict:params];
111+
self.clearLocalURL = TRUE;
112+
}
113+
}
114+
}
103115

104116
BNCApplication *application = [BNCApplication currentApplication];
105117
params[@"lastest_update_time"] = BNCWireFormatFromDate(application.currentBuildDate);
@@ -269,6 +281,13 @@ - (void)processResponse:(BNCServerResponse *)response error:(NSError *)error {
269281
preferenceHelper.randomizedBundleToken = string;
270282
}
271283

284+
if (self.clearLocalURL) {
285+
preferenceHelper.localUrl = nil;
286+
#if !TARGET_OS_TV
287+
UIPasteboard.generalPasteboard.URL = nil;
288+
#endif
289+
}
290+
272291
[BranchOpenRequest releaseOpenResponseLock];
273292

274293
BranchContentDiscoveryManifest *cdManifest = [BranchContentDiscoveryManifest getInstance];

0 commit comments

Comments
 (0)