Skip to content

Commit 15e2a9e

Browse files
Merge pull request #425 from AppsFlyerSDK/releases/6.x.x/6.9.x/6.9.1-rc1
Releases/6.x.x/6.9.x/6.9.1 rc1
2 parents c19d3d6 + fd91354 commit 15e2a9e

14 files changed

Lines changed: 197 additions & 19 deletions

File tree

.github/workflows/scripts/releaseNotesGenerator.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ JIRA_TOKEN=$1
22
JIRA_FIXED_VERSION=$2
33

44
fixed_version_found=false
5-
curl -X GET -H "Authorization: Basic $JIRA_TOKEN=" https://appsflyer.atlassian.net/rest/api/3/project/11400/versions | jq -r '.[] | .name+""+.id' | while read version ; do
5+
curl -X GET -H "Authorization: Basic $JIRA_TOKEN=" https://appsflyer.atlassian.net/rest/api/3/project/11723/versions | jq -r '.[] | .name+""+.id' | while read version ; do
66
if [[ "$version" == *"$JIRA_FIXED_VERSION"* ]] ;then
77
echo "$JIRA_FIXED_VERSION Found!"
88
fixed_version_found=true

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ local.properties
3636
android/gradlew.bat
3737
.vscode
3838
android/gradle
39+
android/gradlew
3940
android/.project
4041

4142
# node.js
@@ -50,7 +51,7 @@ buck-out/
5051
android/app/libs
5152
android/keystores/debug.keystore
5253

53-
54+
.watchmanconfig
5455
coverage/
5556
package-lock.json
5657

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 6.9.1
2+
Release date: *2022-09-22*
3+
4+
- React Native >> Support Deep Linking without calling startSDK()
5+
- React Native >> Separate between initSDK and startSDK
6+
17
## 6.8.2
28
Release date: *2022-08-30*
39

Docs/API.md

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
The list of available methods for this plugin is described below.
55
- [Android & iOS APIs](#allAPI)
66
- [initSDK](#initSDK)
7+
- [startSdk](#startSdk)
78
- [logEvent](#logEvent)
89
- [setCustomerUserId](#setCustomerUserId)
910
- [stop](#stop)
@@ -30,6 +31,7 @@ The list of available methods for this plugin is described below.
3031
- [setCollectAndroidID](#setCollectAndroidID)
3132
- [setCollectIMEI](#setCollectIMEI)
3233
- [setDisableNetworkData](#setDisableNetworkData)
34+
- [performOnDeepLinking](#performOnDeepLinking)
3335
- [iOS Only APIs](#iOSOnly)
3436
- [disableCollectASA](#disableCollectASA)
3537
- [setUseReceiptValidationSandbox](#setUseReceiptValidationSandbox)
@@ -64,6 +66,7 @@ The dev key is required for all apps and the appID is required only for iOS.<br/
6466
|onInstallConversionDataListener| Set listener for [GCD](https://dev.appsflyer.com/hc/docs/conversion-data) response (Optional. default=true) |
6567
|onDeepLinkListener| Set listener for [UDL](https://dev.appsflyer.com/hc/docs/unified-deep-linking-udl) response (Optional. default=false) |
6668
|timeToWaitForATTUserAuthorization| Waits for request user authorization to access app-related data. please read more [Here](https://dev.appsflyer.com/hc/docs/ios-sdk-reference-appsflyerlib#waitforattuserauthorization) |
69+
|manualStart| Prevents from the SDK from sending the launch request after using appsFlyer.initSdk(...). When using this property, the apps needs to manually trigger the appsFlyer.startSdk() API to report the app launch. read more [here](#startSdk). (Optional, default=false) |
6770
*Example:*
6871

6972
```javascript
@@ -78,7 +81,8 @@ appsFlyer.initSdk(
7881
appId: '41*****44',
7982
onInstallConversionDataListener: false, //Optional
8083
onDeepLinkListener: true, //Optional
81-
timeToWaitForATTUserAuthorization: 10 //for iOS 14.5
84+
timeToWaitForATTUserAuthorization: 10, //for iOS 14.5
85+
manualStart: true, //Optional
8286
},
8387
(res) => {
8488
console.log(res);
@@ -88,6 +92,44 @@ appsFlyer.initSdk(
8892
}
8993
);
9094
```
95+
96+
---
97+
98+
##### <a id="startSdk"> **`startSdk()`**
99+
100+
In version 6.9.1 of the react-native-appslfyer SDK we added the option of splitting between the initialization stage and start stage. All you need to do is add the property manualStart: true to the init object, and later call appsFlyer.startSdk() whenever you decide. If this property is set to false or doesn’t exist, the sdk will start after calling `appsFlyer.initSdk(...)`.
101+
102+
*Example:*
103+
```javascript
104+
const option = {
105+
isDebug: true,
106+
devKey: 'UsxXxXxed',
107+
appId: '75xXxXxXxXx11',
108+
onInstallConversionDataListener: true,
109+
onDeepLinkListener: true,
110+
timeToWaitForATTUserAuthorization: 5,
111+
manualStart: true, // <--- for manual start.
112+
};
113+
114+
appsFlyer.initSdk(
115+
option,
116+
() => {
117+
if (!option.manualStart) {
118+
console.warn('AppsFlyer SDK started!');
119+
} else {
120+
console.warn('AppsFlyer SDK init, didn\'t send launch yet');
121+
}
122+
},
123+
err => {
124+
// handle error
125+
},
126+
);
127+
//...
128+
// app flow
129+
//...
130+
131+
appsFlyer.startSdk(); // <--- Here we send launch
132+
```
91133
---
92134

93135
##### <a id="logEvent"> **`logEvent(eventName, eventValues, success, error)`**
@@ -713,13 +755,57 @@ Use to opt-out of collecting the network operator name (carrier) and sim operato
713755

714756

715757
*Example:*
716-
717758
```javascript
718759
if (Platform.OS == 'android') {
719760
appsFlyer.setDisableNetworkData(true);
720761
}
721762
```
722763

764+
##### <a id="performOnDeepLinking"> **`performOnDeepLinking()`**
765+
766+
Enables manual triggering of deep link resolution. This method allows apps that are delaying the call to `appsFlyer.startSdk()` to resolve deep links before the SDK starts.<br>
767+
Note:<br>This API will trigger the `appsFlyer.onDeepLink` callback. In the following example, we check if `res.deepLinkStatus` is equal to “FOUND” inside `appsFlyer.onDeepLink` callback to extract the deeplink parameters.
768+
769+
*Example:*
770+
```javascript
771+
// Let's say we want the resolve a deeplink and get the deeplink params when the user clicks on it but delay the actual 'start' of the sdk (not sending launch to appsflyer).
772+
773+
const option = {
774+
isDebug: true,
775+
devKey: 'UsxXxXxed',
776+
appId: '75xXxXxXxXx11',
777+
onInstallConversionDataListener: true,
778+
onDeepLinkListener: true,
779+
manualStart: true, // <--- for manual start.
780+
};
781+
782+
const onDeepLink = appsFlyer.onDeepLink(res => {
783+
if (res.deepLinkStatus == 'FOUND') {
784+
// here we will get the deeplink params after resolving it.
785+
// more flow...
786+
}
787+
});
788+
789+
appsFlyer.initSdk(
790+
option,
791+
() => {
792+
if (!option.manualStart) {
793+
console.warn('AppsFlyer SDK started!');
794+
} else {
795+
console.warn('AppsFlyer SDK init, didn\'t send launch yet');
796+
}
797+
},
798+
() => {},
799+
);
800+
801+
if (Platform.OS == 'android') {
802+
appsFlyer.performOnDeepLinking();
803+
}
804+
805+
// more app flow...
806+
807+
appsFlyer.startSdk(); // <--- Here we send launch
808+
```
723809
## <a id="iOSOnly"> iOS Only APIs
724810

725811
##### <a id="disableCollectASA"> **`disableCollectASA(shouldDisable)`**

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
### <a id="plugin-build-for"> This plugin is built for
1515

16-
- Android AppsFlyer SDK **v6.8.2**
16+
- Android AppsFlyer SDK **v6.9.1**
1717
- iOS AppsFlyer SDK **v6.8.1**
1818

1919
## <a id="breaking-changes"> ❗❗ Breaking changes when updating to v6.x.x❗❗

__tests__/index.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,36 @@ describe("Test appsFlyer API's", () => {
205205
appsFlyer.sendPushNotificationData({ foo: 'bar' });
206206
expect(RNAppsFlyer.sendPushNotificationData).toHaveBeenCalledTimes(1);
207207
});
208+
209+
test('it calls appsFlyer.appendParametersToDeepLinkingURL(dummy-url, foo)', () => {
210+
appsFlyer.appendParametersToDeepLinkingURL('dummy-url', 'foo');
211+
expect(RNAppsFlyer.appendParametersToDeepLinkingURL).toHaveBeenCalledTimes(0);
212+
});
213+
214+
test('it calls appsFlyer.appendParametersToDeepLinkingURL(dummy-url, boolean)', () => {
215+
appsFlyer.appendParametersToDeepLinkingURL('dummy-url', true);
216+
expect(RNAppsFlyer.appendParametersToDeepLinkingURL).toHaveBeenCalledTimes(0);
217+
});
218+
219+
test('it calls appsFlyer.appendParametersToDeepLinkingURL(dummy-url, {})', () => {
220+
appsFlyer.appendParametersToDeepLinkingURL('dummy-url', {});
221+
expect(RNAppsFlyer.appendParametersToDeepLinkingURL).toHaveBeenCalledTimes(1);
222+
});
223+
224+
test('it calls appsFlyer.setDisableNetworkData(true)', () => {
225+
appsFlyer.setDisableNetworkData(true);
226+
expect(RNAppsFlyer.setDisableNetworkData).toHaveBeenCalledTimes(1);
227+
});
228+
229+
test('it calls appsFlyer.startSdk()', () => {
230+
appsFlyer.startSdk();
231+
expect(RNAppsFlyer.startSdk).toHaveBeenCalledTimes(1);
232+
});
233+
234+
test('it calls appsFlyer.performOnDeepLinking()', () => {
235+
appsFlyer.performOnDeepLinking();
236+
expect(RNAppsFlyer.performOnDeepLinking).toHaveBeenCalledTimes(1);
237+
});
208238
});
209239

210240
describe('Test native event emitter', () => {

__tests__/setup.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jest.mock('../node_modules/react-native/Libraries/BatchedBridge/NativeModules',
1818
setSharingFilterForPartners: jest.fn(),
1919
setCurrentDeviceLanguage: jest.fn(),
2020
sendPushNotificationData: jest.fn(),
21+
appendParametersToDeepLinkingURL: jest.fn(),
22+
setDisableNetworkData: jest.fn(),
23+
performOnDeepLinking: jest.fn(),
24+
startSdk: jest.fn(),
2125
},
2226
};
2327
});

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ repositories {
5454
dependencies {
5555
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
5656
implementation "com.android.installreferrer:installreferrer:${safeExtGet('installReferrerVersion', '2.1')}"
57-
implementation "com.appsflyer:af-android-sdk:${safeExtGet('appsflyerVersion', '6.8.2')}"
57+
implementation "com.appsflyer:af-android-sdk:${safeExtGet('appsflyerVersion', '6.9.1')}"
5858
}

android/src/main/java/com/appsflyer/reactnative/RNAppsFlyerModule.java

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ public class RNAppsFlyerModule extends ReactContextBaseJavaModule {
5050

5151
private ReactApplicationContext reactContext;
5252
private Application application;
53+
private String personalDevKey;
5354

5455
public RNAppsFlyerModule(ReactApplicationContext reactContext) {
5556
super(reactContext);
5657
this.reactContext = reactContext;
5758
this.application = (Application) reactContext.getApplicationContext();
59+
this.personalDevKey = "";
5860
}
5961

6062
@Override
@@ -128,13 +130,16 @@ private String callSdkInternal(ReadableMap _options) {
128130
boolean isDebug;
129131
boolean isConversionData;
130132
boolean isDeepLinking;
133+
boolean isManualStartMode;
131134

132135
AppsFlyerLib instance = AppsFlyerLib.getInstance();
133136
JSONObject options = RNUtil.readableMapToJson(_options);
134137
devKey = options.optString(afDevKey, "");
135138
if (devKey.trim().equals("")) {
136139
return NO_DEVKEY_FOUND;
137140
}
141+
this.personalDevKey = devKey;
142+
138143
isDebug = options.optBoolean(afIsDebug, false);
139144
instance.setDebugLog(isDebug);
140145

@@ -143,22 +148,15 @@ private String callSdkInternal(ReadableMap _options) {
143148
Log.d("AppsFlyer", "Starting SDK");
144149
}
145150
isDeepLinking = options.optBoolean(afDeepLink, false);
151+
isManualStartMode = options.optBoolean("manualStart", false);
146152

147153
instance.init(devKey, (isConversionData == true) ? registerConversionListener() : null, application.getApplicationContext());
148154
if (isDeepLinking) {
149155
instance.subscribeForDeepLink(registerDeepLinkListener());
150156
}
151-
Intent intent = null;
152-
Activity currentActivity = getCurrentActivity();
153157

154-
if (currentActivity != null) {
155-
// register for lifecycle with Activity (automatically fetching deeplink from Activity if present)
156-
instance.start(currentActivity, devKey);
157-
} else {
158-
// register for lifecycle with Application (cannot fetch deeplink without access to the Activity,
159-
// also sending first session manually)
160-
instance.logEvent(application, null, null);
161-
instance.start(application, devKey);
158+
if (!isManualStartMode) {
159+
startSdk();
162160
}
163161
return null;
164162
}
@@ -262,6 +260,20 @@ private void sendEvent(ReactContext reactContext,
262260
.emit(eventName, params);
263261
}
264262

263+
@ReactMethod
264+
public void startSdk() {
265+
Activity currentActivity = getCurrentActivity();
266+
if (currentActivity != null) {
267+
// register for lifecycle with Activity (automatically fetching deeplink from Activity if present)
268+
AppsFlyerLib.getInstance().start(currentActivity, this.personalDevKey);
269+
} else {
270+
// register for lifecycle with Application (cannot fetch deeplink without access to the Activity,
271+
// also sending first session manually)
272+
AppsFlyerLib.getInstance().logEvent(this.application, null, null);
273+
AppsFlyerLib.getInstance().start(this.application, this.personalDevKey);
274+
}
275+
}
276+
265277
@ReactMethod
266278
public void logEvent(
267279
final String eventName, ReadableMap eventData,
@@ -766,6 +778,21 @@ public void appendParametersToDeepLinkingURL(String contains, ReadableMap parame
766778
public void setDisableNetworkData(Boolean disabled) {
767779
AppsFlyerLib.getInstance().setDisableNetworkData(disabled);
768780
}
781+
782+
@ReactMethod
783+
public void performOnDeepLinking() {
784+
Activity activity = getCurrentActivity();
785+
if (activity != null) {
786+
Intent intent = activity.getIntent();
787+
if (intent != null) {
788+
AppsFlyerLib.getInstance().performOnDeepLinking(intent, this.application);
789+
} else {
790+
Log.d("AppsFlyer", "performOnDeepLinking: intent is null!");
791+
}
792+
} else{
793+
Log.d("AppsFlyer", "performOnDeepLinking: activity is null!");
794+
}
795+
}
769796

770797
@ReactMethod
771798
public void addListener(String eventName) {

index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ declare module "react-native-appsflyer" {
7979
onInstallConversionDataListener?: boolean;
8080
onDeepLinkListener?: boolean;
8181
timeToWaitForATTUserAuthorization?: number; // iOS only
82+
manualStart?: boolean
8283
}
8384

8485
export interface InAppPurchase {
@@ -142,6 +143,7 @@ declare module "react-native-appsflyer" {
142143
setSharingFilterForPartners(partners: string[]): void
143144
setPartnerData(partnerId: string, partnerData: object): void
144145
appendParametersToDeepLinkingURL(contains: string, parameters: object): void
146+
startSdk(): void
145147

146148
/**
147149
* For iOS Only
@@ -157,6 +159,7 @@ declare module "react-native-appsflyer" {
157159
setCollectIMEI(isCollect: boolean, successC?: SuccessCB): void
158160
setCollectAndroidID(isCollect: boolean, successC?: SuccessCB): void
159161
setDisableNetworkData(disable: boolean): void
162+
performOnDeepLinking(): void
160163
};
161164

162165
export default appsFlyer;

0 commit comments

Comments
 (0)