Skip to content

Commit

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

Releases/6.x.x/6.15.x/6.15.1 rc1
  • Loading branch information
al-af authored Sep 15, 2024
2 parents d8b0801 + a1d466e commit 8f066e2
Show file tree
Hide file tree
Showing 25 changed files with 406 additions and 42 deletions.
35 changes: 21 additions & 14 deletions .github/workflows/build-apps-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@ on:

jobs:
Build-RN-android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: install react-native-appsflyer on an Android app
run: |
cd demos/appsflyer-react-native-app
yarn install
yarn add ../../ --save
- name: Build apk
run: |
cd demos/appsflyer-react-native-app/android
chmod +x ./gradlew
./gradlew assembleRelease
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'

- name: install react-native-appsflyer on an Android app
run: |
cd demos/appsflyer-react-native-app
yarn install
yarn add ../../ --save
- name: Build apk
run: |
cd demos/appsflyer-react-native-app/android
chmod +x ./gradlew
./gradlew assembleRelease
# Build-RN-ios:
# runs-on: macos-latest
# steps:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/scripts/updateReadme.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

ios_sdk_version=$(cat react-native-appsflyer.podspec | grep '\'AppsFlyerFramework\' | grep -Eo '[0-9].[0-9]+.[0-9]+')
android_sdk_version=$(cat android/build.gradle | grep 'com.appsflyer:af-android-sdk' | grep -Eo '[0-9].[0-9]+.[0-9]+')
sed -i -e -r "s/Android AppsFlyer SDK \*\*v[0-9].[0-9]+.[0-9]+\*\*/Android AppsFlyer SDK \*\*v$android_sdk_version\*\*/g" README.md
sed -i -e -r "s/iOS AppsFlyer SDK \*\*v[0-9].[0-9]+.[0-9]+\*\*/iOS AppsFlyer SDK \*\*v$ios_sdk_version\*\*/g" README.md
ios_sdk_version=$(cat react-native-appsflyer.podspec | grep '\'AppsFlyerFramework\' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
android_sdk_version=$(cat android/build.gradle | grep 'com.appsflyer:af-android-sdk' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
sed -i -r "s/Android AppsFlyer SDK \*\*v[0-9]+\.[0-9]+\.[0-9]+\*\*/Android AppsFlyer SDK \*\*v$android_sdk_version\*\*/g" README.md
sed -i -r "s/iOS AppsFlyer SDK \*\*v[0-9]+\.[0-9]+\.[0-9]+\*\*/iOS AppsFlyer SDK \*\*v$ios_sdk_version\*\*/g" README.md
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ demos/appsflyer-expo-app/android
demos/appsflyer-expo-app/.expo
demos/appsflyer-expo-app/node_modules
demos/appsflyer-expo-app/yarn.lock

demos/appsflyer-react-native-app/ios/AppsFlyerExample.xcodeproj/project.pbxproj
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 6.15.1
Release date: *2024-09-15*

- React Native >> Update Plugin to v6.15.1
- React native plugin >> UDL failed deferred deep linking

## 6.14.3
Release date: *2024-04-28*

Expand Down
40 changes: 40 additions & 0 deletions Docs/RN_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The list of available methods for this plugin is described below.
- [disableAdvertisingIdentifier](#disableAdvertisingIdentifier)
- [enableTCFDataCollection](#enableTCFDataCollection)
- [setConsentData](#setConsentData)
- [logAdRevenue](#logAdRevenue)
- [Android Only APIs](#android-only-apis)
- [setCollectAndroidID](#setcollectandroidid)
- [setCollectIMEI](#setcollectimei)
Expand Down Expand Up @@ -797,6 +798,45 @@ let GDPRUser = AppsFlyerConsent.forGDPRUser(true, false);
appsFlyer.setConsentData(nonGDPRUser /**or**/ GDPRUser);
```

### logAdRevenue - Since 6.15.1
`logAdRevenue(data: AFAdRevenueData): void`

Use this method to log your ad revenue.</br>
By attributing ad revenue, app owners gain the complete view of user LTV and campaign ROI.
Ad revenue is generated by displaying ads on rewarded videos, offer walls, interstitials, and banners in an app.

#### Parameters

| Param | Type |
| -------------- | ---------------------------------------------------------- |
| **`data`** | `AFAdRevenueData` |

#### Usage Example for React Native:

```javascript
const adRevenueData = {
monetizationNetwork: 'AF-AdNetwork',
mediationNetwork: MEDIATION_NETWORK.IRONSOURCE,
currencyIso4217Code: 'USD',
revenue: 1.23,
additionalParameters: {
customParam1: 'value1',
customParam2: 'value2',
}
};

appsFlyer.logAdRevenue(adRevenueData);
```

Here's how you use `appsFlyer.logAdRevenue` within a React Native app:

1. Prepare the `adRevenueData` object as shown, including any additional parameters you wish to track along with the ad revenue event.
2. Call the `appsFlyer.logAdRevenue` method with the `adRevenueData` object.

By passing all the required fields in `AFAdRevenueData`, you help ensure accurate tracking within the AppsFlyer platform. This enables you to analyze your ad revenue alongside other user acquisition data to optimize your app's overall monetization strategy.

**Note:** The `additionalParameters` object is optional. You can add any additional data you want to log with the ad revenue event in this object. This can be useful for detailed analytics or specific event tracking later on. Make sure that the custom parameters follow the data types and structures specified by AppsFlyer in their documentation.

## Android Only APIs

### setCollectAndroidID
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

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

- From version `6.15.1`, upgraded to targetSDKVersion 34, Java 17, and Gradle 8.7 in [AppsFlyer Android SDK v6.15.1](https://support.appsflyer.com/hc/en-us/articles/115001256006-AppsFlyer-Android-SDK-release-notes).

- From version `6.15.1`, iOS Minimum deployment target is set to 12.0.

- From version `6.3.0`, we use `xcframework` for iOS platform. Then you need to use cocoapods version >= 1.10

- From version `6.2.30`, `logCrossPromotionAndOpenStore` api will register as `af_cross_promotion` instead of `af_app_invites` in your dashboard.<br>
Expand Down
10 changes: 5 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:7.2.2'
}
}


apply plugin: 'com.android.library'

android {
compileSdkVersion safeExtGet('compileSdkVersion', 28)
buildToolsVersion safeExtGet('buildToolsVersion', '29.0.2')
compileSdkVersion safeExtGet('compileSdkVersion', 34)
buildToolsVersion safeExtGet('buildToolsVersion', '34.0.0')

defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 28)
targetSdkVersion safeExtGet('targetSdkVersion', 34)
versionCode 1
versionName "1.0"
ndk {
Expand Down 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')}"
api "com.appsflyer:af-android-sdk:${safeExtGet('appsflyerVersion', '6.14.0')}"
api "com.appsflyer:af-android-sdk:${safeExtGet('appsflyerVersion', '6.15.1')}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class RNAppsFlyerConstants {

final static String PLUGIN_VERSION = "6.14.3";
final static String PLUGIN_VERSION = "6.15.1";
final static String NO_DEVKEY_FOUND = "No 'devKey' found or its empty";
final static String UNKNOWN_ERROR = "AF Unknown Error";
final static String SUCCESS = "Success";
Expand Down Expand Up @@ -52,5 +52,11 @@ public class RNAppsFlyerConstants {
final static String VALIDATE_SUCCESS = "In-App Purchase Validation success";
final static String VALIDATE_FAILED = "In-App Purchase Validation failed with error: ";

final static String MONETIZATION_NETWORK = "monetizationNetwork";
final static String CURRENCY_ISO4217_CODE = "currencyIso4217Code";
final static String AF_REVENUE = "revenue";
final static String AF_MEDIATION_NETWORK = "mediationNetwork";
final static String AF_ADDITIONAL_PARAMETERS = "additionalParameters";

}

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.modules.core.DeviceEventManagerModule;

Expand Down Expand Up @@ -362,6 +363,59 @@ public void onError(int i, @NonNull String s) {
}
}

@ReactMethod
public void logAdRevenue(ReadableMap adRevenueDictionary) {
if (adRevenueDictionary == null || !adRevenueDictionary.keySetIterator().hasNextKey()) {
Log.d("AppsFlyer", "adRevenueData is missing, the data is mandatory to use this API.");
return;
}

String monetizationNetwork = adRevenueDictionary.getString(MONETIZATION_NETWORK);
if (monetizationNetwork == null) {
Log.d("AppsFlyer", "monetizationNetwork is missing");
return;
}

String currencyIso4217Code = adRevenueDictionary.getString(CURRENCY_ISO4217_CODE);
if (currencyIso4217Code == null) {
Log.d("AppsFlyer", "currencyIso4217Code is missing");
return;
}

if (!adRevenueDictionary.hasKey(AF_REVENUE) || adRevenueDictionary.getType(AF_REVENUE) != ReadableType.Number) {
Log.d("AppsFlyer", "revenue is missing or not a number");
return;
}
double revenue = adRevenueDictionary.getDouble(AF_REVENUE);

ReadableMap additionalParameters = null;
if (adRevenueDictionary.hasKey(AF_ADDITIONAL_PARAMETERS) && adRevenueDictionary.getType(AF_ADDITIONAL_PARAMETERS) == ReadableType.Map) {
additionalParameters = adRevenueDictionary.getMap(AF_ADDITIONAL_PARAMETERS);
}

String mediationNetworkValue = adRevenueDictionary.getString(AF_MEDIATION_NETWORK);
if (mediationNetworkValue == null || mediationNetworkValue.isEmpty()) {
Log.d("AppsFlyer", "mediationNetwork is missing");
return;
}

MediationNetwork mediationNetwork = MediationNetwork.valueOf(mediationNetworkValue.toUpperCase());
if (mediationNetwork == null) {
Log.d("AppsFlyer", "Invalid mediation network");
return;
}

AFAdRevenueData adRevenueData = new AFAdRevenueData(
monetizationNetwork,
mediationNetwork,
currencyIso4217Code,
revenue
);

// Log the ad revenue to the AppsFlyer SDK
AppsFlyerLib.getInstance().logAdRevenue(adRevenueData, RNUtil.toMap(additionalParameters));
}

@ReactMethod
public void getAppsFlyerUID(Callback callback) {
String appId = AppsFlyerLib.getInstance().getAppsFlyerUID(getReactApplicationContext());
Expand Down
1 change: 1 addition & 0 deletions demos/appsflyer-react-native-app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'org.jetbrains:annotations:16.0.2'

implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import org.jetbrains.annotations.Nullable;
import android.content.Context;

public class MainApplication extends Application implements ReactApplication {

Expand Down Expand Up @@ -40,6 +46,15 @@ public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@Override
public Intent registerReceiver(@Nullable BroadcastReceiver receiver, IntentFilter filter) {
if (Build.VERSION.SDK_INT >= 34 && getApplicationInfo().targetSdkVersion >= 34) {
return super.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED);
} else {
return super.registerReceiver(receiver, filter);
}
}

@Override
public void onCreate() {
super.onCreate();
Expand Down
9 changes: 5 additions & 4 deletions demos/appsflyer-react-native-app/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

buildscript {
ext {
buildToolsVersion = "30.0.2"
buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 32
targetSdkVersion = 32
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "20.1.5948944"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.1")
//classpath("com.android.tools.build:gradle:4.2.1")
classpath("com.android.tools.build:gradle:7.1.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
2 changes: 1 addition & 1 deletion demos/appsflyer-react-native-app/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=4g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Sun Sep 01 10:19:20 IDT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 17 additions & 1 deletion demos/appsflyer-react-native-app/components/AppsFlyer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import appsFlyer from 'react-native-appsflyer';
import appsFlyer , {MEDIATION_NETWORK} from 'react-native-appsflyer';
import {Platform} from 'react-native';

// events
Expand Down Expand Up @@ -29,4 +29,20 @@ export function AFInit() {
// Sends in-app events to AppsFlyer servers. name is the events name ('simple event') and the values are a JSON ({info: 'fff', size: 5})
export function AFLogEvent(name, values) {
appsFlyer.logEvent(name, values, null, null);
AFLogAdRevenue();
}

export function AFLogAdRevenue(){
const adRevenueData = {
monetizationNetwork: 'AF-AdNetwork',
mediationNetwork: MEDIATION_NETWORK.IRONSOURCE,
currencyIso4217Code: 'USD',
revenue: 1.23,
additionalParameters : {
customParam1: 'value1',
customParam2: 'value2',
}
};

appsFlyer.logAdRevenue(adRevenueData);
}
11 changes: 11 additions & 0 deletions demos/appsflyer-react-native-app/ios/.xcode.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This `.xcode.env` file is versioned and is used to source the environment
# used when running script phases inside Xcode.
# To customize your local environment, you can create an `.xcode.env.local`
# file that is not versioned.

# NODE_BINARY variable contains the PATH to the node executable.
#
# Customize the NODE_BINARY variable here.
# For example, to use nvm with brew, add the following line
# . "$(brew --prefix nvm)/nvm.sh" --no-use
export NODE_BINARY=$(command -v node)
4 changes: 2 additions & 2 deletions demos/appsflyer-react-native-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"@react-navigation/stack": "^6.0.7",
"react": "18.1.0",
"react-native": "0.70.6",
"react-native-appsflyer": "file:../..",
"react-native-appsflyer": "../../",
"react-native-elements": "^3.4.2",
"react-native-gesture-handler": "^1.10.3",
"react-native-safe-area-context": "^3.3.2",
"react-native-screens": "3.7.2",
"react-native-screens": "^3.34.0",
"react-native-vector-icons": "8.1.0"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit 8f066e2

Please sign in to comment.