Skip to content

Commit f487b8c

Browse files
Merge pull request #124 from BranchMetrics/SDK-2050
[SDK-2050] Added referringParams methods
2 parents 9c6e2e4 + aa362c9 commit f487b8c

File tree

7 files changed

+72
-20
lines changed

7 files changed

+72
-20
lines changed

android/src/main/java/co/boundstate/BranchDeepLinks.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,4 +518,18 @@ private BranchShareSheetBuilder getShareLinkBuilder(BranchShortLinkBuilder short
518518

519519
return shareLinkBuilder;
520520
}
521+
522+
@PluginMethod
523+
public void getLatestReferringParams(PluginCall call) {
524+
JSObject ret = new JSObject();
525+
ret.put("referringParams", Branch.getInstance().getLatestReferringParams());
526+
call.resolve(ret);
527+
}
528+
529+
@PluginMethod
530+
public void getFirstReferringParams(PluginCall call) {
531+
JSObject ret = new JSObject();
532+
ret.put("referringParams", Branch.getInstance().getFirstReferringParams());
533+
call.resolve(ret);
534+
}
521535
}

ios/Plugin/BranchService.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,18 @@ class BranchService {
4343
completion(nil, error)
4444
} else if let qrCodeData = qrCodeData {
4545
let qrCodeString = qrCodeData.base64EncodedString()
46-
completion(qrCodeString,nil)
46+
completion(qrCodeString, nil)
4747
}
4848
}
4949
}
50+
51+
func getLatestReferringParams(completion: @escaping ([AnyHashable: Any])->(Void)) -> Void {
52+
let params = Branch.getInstance().getLatestReferringParams() ?? [:]
53+
completion(params)
54+
}
55+
56+
func getFirstReferringParams(completion: @escaping ([AnyHashable : Any])->(Void)) -> Void {
57+
let params = Branch.getInstance().getFirstReferringParams() ?? [:]
58+
completion(params)
59+
}
5060
}

ios/Plugin/Plugin.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@
1313
CAP_PLUGIN_METHOD(setIdentity, CAPPluginReturnPromise);
1414
CAP_PLUGIN_METHOD(logout, CAPPluginReturnPromise);
1515
CAP_PLUGIN_METHOD(getBranchQRCode, CAPPluginReturnPromise);
16+
CAP_PLUGIN_METHOD(getLatestReferringParams, CAPPluginReturnPromise);
17+
CAP_PLUGIN_METHOD(getFirstReferringParams, CAPPluginReturnPromise);
1618
)

ios/Plugin/Plugin.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,4 +313,20 @@ public class BranchDeepLinks: CAPPlugin {
313313
hexInt = UInt32(bitPattern: scanner.scanInt32(representation: .hexadecimal) ?? 0)
314314
return hexInt
315315
}
316+
317+
@objc func getLatestReferringParams(_ call: CAPPluginCall) {
318+
branchService.getLatestReferringParams() { (params) in
319+
call.resolve([
320+
"referringParams": params
321+
])
322+
}
323+
}
324+
325+
@objc func getFirstReferringParams(_ call: CAPPluginCall) {
326+
branchService.getFirstReferringParams() { (params) in
327+
call.resolve([
328+
"referringParams": params
329+
])
330+
}
331+
}
316332
}

ios/Podfile.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
PODS:
2-
- BranchSDK (2.2.0)
3-
- Capacitor (5.0.5):
2+
- BranchSDK (3.0.1)
3+
- Capacitor (5.5.1):
44
- CapacitorCordova
5-
- CapacitorCordova (5.0.5)
5+
- CapacitorCordova (5.5.1)
66

77
DEPENDENCIES:
8-
- BranchSDK (~> 2.2.0)
8+
- BranchSDK (~> 3.0.1)
99
- "Capacitor (from `../node_modules/@capacitor/ios`)"
1010
- "CapacitorCordova (from `../node_modules/@capacitor/ios`)"
1111

@@ -20,10 +20,10 @@ EXTERNAL SOURCES:
2020
:path: "../node_modules/@capacitor/ios"
2121

2222
SPEC CHECKSUMS:
23-
BranchSDK: 8749d10e30725d08b6c188ab90e6fd6223d204db
24-
Capacitor: b1248915663add1bd6567e2b67c1c1fa3abcf5e8
25-
CapacitorCordova: f8c06b897c74ee8f7701fe10e6443b40822bc83a
23+
BranchSDK: e268bcf41469051c9e83efcd6fd85d0ba91d1d0f
24+
Capacitor: 9da0a2415e3b6098511f8b5ffdb578d91ee79f8f
25+
CapacitorCordova: e128cc7688c070ca0bfa439898a5f609da8dbcfe
2626

27-
PODFILE CHECKSUM: 8d82a5f2a904341bee78b56626ba4183204a9f0d
27+
PODFILE CHECKSUM: c730e0536dc486077a354a5b012e11d630c85889
2828

29-
COCOAPODS: 1.11.3
29+
COCOAPODS: 1.12.1

src/definitions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export interface BranchDeepLinksPlugin {
9999
metaData: { [key: string]: any };
100100
}): Promise<void>;
101101
handleATTAuthorizationStatus(options: {
102-
status: BranchATTAuthorizationStatus
102+
status: BranchATTAuthorizationStatus;
103103
}): Promise<void>;
104104
disableTracking(options: {
105105
isEnabled: false;
@@ -108,7 +108,7 @@ export interface BranchDeepLinksPlugin {
108108
newIdentity: string;
109109
}): Promise<BranchReferringParamsResponse>;
110110
logout(): Promise<BranchLoggedOutResponse>;
111-
getBranchQRCode(
112-
options: BranchQRCodeParams,
113-
): Promise<BranchQRCodeResponse>;
111+
getBranchQRCode(options: BranchQRCodeParams): Promise<BranchQRCodeResponse>;
112+
getLatestReferringParams(): Promise<BranchReferringParamsResponse>;
113+
getFirstReferringParams(): Promise<BranchReferringParamsResponse>;
114114
}

src/web.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import {
1313
BranchQRCodeResponse,
1414
} from './definitions';
1515

16-
export class BranchDeepLinksWeb extends WebPlugin
17-
implements BranchDeepLinksPlugin {
16+
export class BranchDeepLinksWeb
17+
extends WebPlugin
18+
implements BranchDeepLinksPlugin
19+
{
1820
constructor() {
1921
super({
2022
name: 'BranchDeepLinks',
@@ -55,9 +57,7 @@ export class BranchDeepLinksWeb extends WebPlugin
5557
);
5658
}
5759

58-
handleATTAuthorizationStatus(_: {
59-
status: number
60-
}): Promise<void> {
60+
handleATTAuthorizationStatus(_: { status: number }): Promise<void> {
6161
return Promise.reject(
6262
new Error('BranchDeepLinks does not have web implementation'),
6363
);
@@ -88,6 +88,16 @@ export class BranchDeepLinksWeb extends WebPlugin
8888
new Error('BranchDeepLinks does not have web implementation'),
8989
);
9090
}
91-
}
9291

92+
getLatestReferringParams(): Promise<BranchReferringParamsResponse> {
93+
return Promise.reject(
94+
new Error('BranchDeepLinks does not have web implementation'),
95+
);
96+
}
9397

98+
getFirstReferringParams(): Promise<BranchReferringParamsResponse> {
99+
return Promise.reject(
100+
new Error('BranchDeepLinks does not have web implementation'),
101+
);
102+
}
103+
}

0 commit comments

Comments
 (0)