Skip to content

Commit

Permalink
Merge pull request AppsFlyerSDK#425 from AppsFlyerSDK/releases/6.x.x/…
Browse files Browse the repository at this point in the history
…6.9.x/6.9.1-rc1

Releases/6.x.x/6.9.x/6.9.1 rc1
  • Loading branch information
amit-kremer93 authored Sep 22, 2022
2 parents c19d3d6 + fd91354 commit 15e2a9e
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scripts/releaseNotesGenerator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ JIRA_TOKEN=$1
JIRA_FIXED_VERSION=$2

fixed_version_found=false
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
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
if [[ "$version" == *"$JIRA_FIXED_VERSION"* ]] ;then
echo "$JIRA_FIXED_VERSION Found!"
fixed_version_found=true
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ local.properties
android/gradlew.bat
.vscode
android/gradle
android/gradlew
android/.project

# node.js
Expand All @@ -50,7 +51,7 @@ buck-out/
android/app/libs
android/keystores/debug.keystore


.watchmanconfig
coverage/
package-lock.json

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 6.9.1
Release date: *2022-09-22*

- React Native >> Support Deep Linking without calling startSDK()
- React Native >> Separate between initSDK and startSDK

## 6.8.2
Release date: *2022-08-30*

Expand Down
90 changes: 88 additions & 2 deletions Docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
The list of available methods for this plugin is described below.
- [Android & iOS APIs](#allAPI)
- [initSDK](#initSDK)
- [startSdk](#startSdk)
- [logEvent](#logEvent)
- [setCustomerUserId](#setCustomerUserId)
- [stop](#stop)
Expand All @@ -30,6 +31,7 @@ The list of available methods for this plugin is described below.
- [setCollectAndroidID](#setCollectAndroidID)
- [setCollectIMEI](#setCollectIMEI)
- [setDisableNetworkData](#setDisableNetworkData)
- [performOnDeepLinking](#performOnDeepLinking)
- [iOS Only APIs](#iOSOnly)
- [disableCollectASA](#disableCollectASA)
- [setUseReceiptValidationSandbox](#setUseReceiptValidationSandbox)
Expand Down Expand Up @@ -64,6 +66,7 @@ The dev key is required for all apps and the appID is required only for iOS.<br/
|onInstallConversionDataListener| Set listener for [GCD](https://dev.appsflyer.com/hc/docs/conversion-data) response (Optional. default=true) |
|onDeepLinkListener| Set listener for [UDL](https://dev.appsflyer.com/hc/docs/unified-deep-linking-udl) response (Optional. default=false) |
|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) |
|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) |
*Example:*

```javascript
Expand All @@ -78,7 +81,8 @@ appsFlyer.initSdk(
appId: '41*****44',
onInstallConversionDataListener: false, //Optional
onDeepLinkListener: true, //Optional
timeToWaitForATTUserAuthorization: 10 //for iOS 14.5
timeToWaitForATTUserAuthorization: 10, //for iOS 14.5
manualStart: true, //Optional
},
(res) => {
console.log(res);
Expand All @@ -88,6 +92,44 @@ appsFlyer.initSdk(
}
);
```

---

##### <a id="startSdk"> **`startSdk()`**

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(...)`.

*Example:*
```javascript
const option = {
isDebug: true,
devKey: 'UsxXxXxed',
appId: '75xXxXxXxXx11',
onInstallConversionDataListener: true,
onDeepLinkListener: true,
timeToWaitForATTUserAuthorization: 5,
manualStart: true, // <--- for manual start.
};

appsFlyer.initSdk(
option,
() => {
if (!option.manualStart) {
console.warn('AppsFlyer SDK started!');
} else {
console.warn('AppsFlyer SDK init, didn\'t send launch yet');
}
},
err => {
// handle error
},
);
//...
// app flow
//...

appsFlyer.startSdk(); // <--- Here we send launch
```
---

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


*Example:*

```javascript
if (Platform.OS == 'android') {
appsFlyer.setDisableNetworkData(true);
}
```

##### <a id="performOnDeepLinking"> **`performOnDeepLinking()`**

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>
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.

*Example:*
```javascript
// 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).

const option = {
isDebug: true,
devKey: 'UsxXxXxed',
appId: '75xXxXxXxXx11',
onInstallConversionDataListener: true,
onDeepLinkListener: true,
manualStart: true, // <--- for manual start.
};

const onDeepLink = appsFlyer.onDeepLink(res => {
if (res.deepLinkStatus == 'FOUND') {
// here we will get the deeplink params after resolving it.
// more flow...
}
});

appsFlyer.initSdk(
option,
() => {
if (!option.manualStart) {
console.warn('AppsFlyer SDK started!');
} else {
console.warn('AppsFlyer SDK init, didn\'t send launch yet');
}
},
() => {},
);

if (Platform.OS == 'android') {
appsFlyer.performOnDeepLinking();
}

// more app flow...

appsFlyer.startSdk(); // <--- Here we send launch
```
## <a id="iOSOnly"> iOS Only APIs

##### <a id="disableCollectASA"> **`disableCollectASA(shouldDisable)`**
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

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

- Android AppsFlyer SDK **v6.8.2**
- Android AppsFlyer SDK **v6.9.1**
- iOS AppsFlyer SDK **v6.8.1**

## <a id="breaking-changes"> ❗❗ Breaking changes when updating to v6.x.x❗❗
Expand Down
30 changes: 30 additions & 0 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,36 @@ describe("Test appsFlyer API's", () => {
appsFlyer.sendPushNotificationData({ foo: 'bar' });
expect(RNAppsFlyer.sendPushNotificationData).toHaveBeenCalledTimes(1);
});

test('it calls appsFlyer.appendParametersToDeepLinkingURL(dummy-url, foo)', () => {
appsFlyer.appendParametersToDeepLinkingURL('dummy-url', 'foo');
expect(RNAppsFlyer.appendParametersToDeepLinkingURL).toHaveBeenCalledTimes(0);
});

test('it calls appsFlyer.appendParametersToDeepLinkingURL(dummy-url, boolean)', () => {
appsFlyer.appendParametersToDeepLinkingURL('dummy-url', true);
expect(RNAppsFlyer.appendParametersToDeepLinkingURL).toHaveBeenCalledTimes(0);
});

test('it calls appsFlyer.appendParametersToDeepLinkingURL(dummy-url, {})', () => {
appsFlyer.appendParametersToDeepLinkingURL('dummy-url', {});
expect(RNAppsFlyer.appendParametersToDeepLinkingURL).toHaveBeenCalledTimes(1);
});

test('it calls appsFlyer.setDisableNetworkData(true)', () => {
appsFlyer.setDisableNetworkData(true);
expect(RNAppsFlyer.setDisableNetworkData).toHaveBeenCalledTimes(1);
});

test('it calls appsFlyer.startSdk()', () => {
appsFlyer.startSdk();
expect(RNAppsFlyer.startSdk).toHaveBeenCalledTimes(1);
});

test('it calls appsFlyer.performOnDeepLinking()', () => {
appsFlyer.performOnDeepLinking();
expect(RNAppsFlyer.performOnDeepLinking).toHaveBeenCalledTimes(1);
});
});

describe('Test native event emitter', () => {
Expand Down
4 changes: 4 additions & 0 deletions __tests__/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jest.mock('../node_modules/react-native/Libraries/BatchedBridge/NativeModules',
setSharingFilterForPartners: jest.fn(),
setCurrentDeviceLanguage: jest.fn(),
sendPushNotificationData: jest.fn(),
appendParametersToDeepLinkingURL: jest.fn(),
setDisableNetworkData: jest.fn(),
performOnDeepLinking: jest.fn(),
startSdk: jest.fn(),
},
};
});
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ repositories {
dependencies {
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
implementation "com.android.installreferrer:installreferrer:${safeExtGet('installReferrerVersion', '2.1')}"
implementation "com.appsflyer:af-android-sdk:${safeExtGet('appsflyerVersion', '6.8.2')}"
implementation "com.appsflyer:af-android-sdk:${safeExtGet('appsflyerVersion', '6.9.1')}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ public class RNAppsFlyerModule extends ReactContextBaseJavaModule {

private ReactApplicationContext reactContext;
private Application application;
private String personalDevKey;

public RNAppsFlyerModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
this.application = (Application) reactContext.getApplicationContext();
this.personalDevKey = "";
}

@Override
Expand Down Expand Up @@ -128,13 +130,16 @@ private String callSdkInternal(ReadableMap _options) {
boolean isDebug;
boolean isConversionData;
boolean isDeepLinking;
boolean isManualStartMode;

AppsFlyerLib instance = AppsFlyerLib.getInstance();
JSONObject options = RNUtil.readableMapToJson(_options);
devKey = options.optString(afDevKey, "");
if (devKey.trim().equals("")) {
return NO_DEVKEY_FOUND;
}
this.personalDevKey = devKey;

isDebug = options.optBoolean(afIsDebug, false);
instance.setDebugLog(isDebug);

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

instance.init(devKey, (isConversionData == true) ? registerConversionListener() : null, application.getApplicationContext());
if (isDeepLinking) {
instance.subscribeForDeepLink(registerDeepLinkListener());
}
Intent intent = null;
Activity currentActivity = getCurrentActivity();

if (currentActivity != null) {
// register for lifecycle with Activity (automatically fetching deeplink from Activity if present)
instance.start(currentActivity, devKey);
} else {
// register for lifecycle with Application (cannot fetch deeplink without access to the Activity,
// also sending first session manually)
instance.logEvent(application, null, null);
instance.start(application, devKey);
if (!isManualStartMode) {
startSdk();
}
return null;
}
Expand Down Expand Up @@ -262,6 +260,20 @@ private void sendEvent(ReactContext reactContext,
.emit(eventName, params);
}

@ReactMethod
public void startSdk() {
Activity currentActivity = getCurrentActivity();
if (currentActivity != null) {
// register for lifecycle with Activity (automatically fetching deeplink from Activity if present)
AppsFlyerLib.getInstance().start(currentActivity, this.personalDevKey);
} else {
// register for lifecycle with Application (cannot fetch deeplink without access to the Activity,
// also sending first session manually)
AppsFlyerLib.getInstance().logEvent(this.application, null, null);
AppsFlyerLib.getInstance().start(this.application, this.personalDevKey);
}
}

@ReactMethod
public void logEvent(
final String eventName, ReadableMap eventData,
Expand Down Expand Up @@ -766,6 +778,21 @@ public void appendParametersToDeepLinkingURL(String contains, ReadableMap parame
public void setDisableNetworkData(Boolean disabled) {
AppsFlyerLib.getInstance().setDisableNetworkData(disabled);
}

@ReactMethod
public void performOnDeepLinking() {
Activity activity = getCurrentActivity();
if (activity != null) {
Intent intent = activity.getIntent();
if (intent != null) {
AppsFlyerLib.getInstance().performOnDeepLinking(intent, this.application);
} else {
Log.d("AppsFlyer", "performOnDeepLinking: intent is null!");
}
} else{
Log.d("AppsFlyer", "performOnDeepLinking: activity is null!");
}
}

@ReactMethod
public void addListener(String eventName) {
Expand Down
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ declare module "react-native-appsflyer" {
onInstallConversionDataListener?: boolean;
onDeepLinkListener?: boolean;
timeToWaitForATTUserAuthorization?: number; // iOS only
manualStart?: boolean
}

export interface InAppPurchase {
Expand Down Expand Up @@ -142,6 +143,7 @@ declare module "react-native-appsflyer" {
setSharingFilterForPartners(partners: string[]): void
setPartnerData(partnerId: string, partnerData: object): void
appendParametersToDeepLinkingURL(contains: string, parameters: object): void
startSdk(): void

/**
* For iOS Only
Expand All @@ -157,6 +159,7 @@ declare module "react-native-appsflyer" {
setCollectIMEI(isCollect: boolean, successC?: SuccessCB): void
setCollectAndroidID(isCollect: boolean, successC?: SuccessCB): void
setDisableNetworkData(disable: boolean): void
performOnDeepLinking(): void
};

export default appsFlyer;
Expand Down
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,14 @@ appsFlyer.setDisableNetworkData = (disable) => {
return RNAppsFlyer.setDisableNetworkData(disable);
};

appsFlyer.startSdk = () => {
return RNAppsFlyer.startSdk();
};

appsFlyer.performOnDeepLinking = () => {
return RNAppsFlyer.performOnDeepLinking();
};

function AFParseJSONException(_message, _data) {
this.message = _message;
this.data = _data;
Expand Down
1 change: 1 addition & 0 deletions ios/RNAppsFlyer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


@interface RNAppsFlyer: RCTEventEmitter <RCTBridgeModule, AppsFlyerLibDelegate, AppsFlyerDeepLinkDelegate>
@property (readwrite, nonatomic) BOOL isManualStart;
@end


Expand Down
Loading

0 comments on commit 15e2a9e

Please sign in to comment.