Skip to content

Commit

Permalink
Merge pull request #338 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
Dani-Koza-AF authored Sep 4, 2024
2 parents 3272d7e + 82764a4 commit 6213341
Show file tree
Hide file tree
Showing 14 changed files with 345 additions and 29 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Versions
## 6.15.1
- Implementation of the new logAdRevenue API for iOS and Android
- Documentation update for the new logAdRevenue API
- Update iOS version to 6.15.1
- Update Android version to 6.15.1
## 6.14.3
- Fixed mapOptions issue with manualStart
- Inherit Privacy Manifest from the native iOS SDK via Cocoapods
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

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

- Android AppsFlyer SDK **v6.14.0**
- iOS AppsFlyer SDK **v6.14.3**
- Android AppsFlyer SDK **v6.15.1**
- iOS AppsFlyer SDK **v6.15.1**

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

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.appsflyer:af-android-sdk:6.14.0'
implementation 'com.appsflyer:af-android-sdk:6.15.1'
implementation 'com.android.installreferrer:installreferrer:2.1'
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.appsflyer.appsflyersdk;

public class AppsFlyerConstants {
final static String PLUGIN_VERSION = "6.14.3";
final static String PLUGIN_VERSION = "6.15.1";
final static String AF_APP_INVITE_ONE_LINK = "appInviteOneLink";
final static String AF_HOST_PREFIX = "hostPrefix";
final static String AF_HOST_NAME = "hostName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
import android.os.Looper;
import android.util.Log;

import com.appsflyer.AFAdRevenueData;
import com.appsflyer.AFLogger;
import com.appsflyer.AppsFlyerConsent;
import com.appsflyer.AppsFlyerConversionListener;
import com.appsflyer.AppsFlyerInAppPurchaseValidatorListener;
import com.appsflyer.AppsFlyerLib;
import com.appsflyer.AppsFlyerProperties;
import com.appsflyer.MediationNetwork;
import com.appsflyer.deeplink.DeepLinkListener;
import com.appsflyer.deeplink.DeepLinkResult;
import com.appsflyer.share.CrossPromotionHelper;
Expand Down Expand Up @@ -344,6 +346,9 @@ public void onMethodCall(MethodCall call, Result result) {
case "addPushNotificationDeepLinkPath":
addPushNotificationDeepLinkPath(call, result);
break;
case "logAdRevenue":
logAdRevenue(call, result);
break;
default:
result.notImplemented();
break;
Expand Down Expand Up @@ -954,6 +959,57 @@ private void logEvent(MethodCall call, MethodChannel.Result result) {
result.success(true);
}

private void logAdRevenue(MethodCall call, Result result) {
try {
String monetizationNetwork = requireNonNullArgument(call, "monetizationNetwork");
String currencyIso4217Code = requireNonNullArgument(call, "currencyIso4217Code");
double revenue = requireNonNullArgument(call,"revenue");
String mediationNetworkString = requireNonNullArgument(call,"mediationNetwork");

MediationNetwork mediationNetwork = MediationNetwork.valueOf(mediationNetworkString.toUpperCase());

// No null check for additionalParameters since it's acceptable for it to be null (optional data)
Map<String, Object> additionalParameters = call.argument("additionalParameters");

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

AppsFlyerLib.getInstance().logAdRevenue(adRevenueData, additionalParameters);
result.success(true);

} catch (IllegalArgumentException e) {
// The IllegalArgumentException could come from either requireNonNullArgument or valueOf methods.
result.error("INVALID_ARGUMENT_PROVIDED", e.getMessage(), null);
}
catch (Throwable t) {
result.error("UNEXPECTED_ERROR", "[logAdRevenue]: An unexpected error occurred: " + t.getMessage(), null);
Log.e("AppsFlyer", "Unexpected exception occurred: [logAdRevenue]", t);
}
}

/**
* Utility method to ensure that an argument with the specified name is not null.
* If the argument is null, this method will throw an IllegalArgumentException.
* The calling method can then terminate immediately without further processing.
*
* @param call The MethodCall from Flutter, containing all the arguments.
* @param argumentName The name of the argument expected in the MethodCall.
* @param <T> The type of the argument being checked for nullity.
* @return The argument value if it is not null; throw IllegalArgumentException otherwise.
*/
private <T> T requireNonNullArgument(MethodCall call, String argumentName) throws IllegalArgumentException {
T argument = call.argument(argumentName);
if (argument == null) {
Log.e("AppsFlyer", "Exception occurred when trying to: " + call.method + "->" + argumentName + " must not be null");
throw new IllegalArgumentException("[" + call.method + "]: " + argumentName + " must not be null");
}
return argument;
}

//RD-65582
private void sendCachedCallbacksToDart() {
if (cachedDeepLinkResult != null) {
Expand Down
101 changes: 95 additions & 6 deletions doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## Types
- [AppsFlyerOptions](#appsflyer-options)
- [AdRevenueData](#AdRevenueData)
- [AFMediationNetwork](#AFMediationNetwork)

## Methods
- [initSdk](#initSdk)
Expand Down Expand Up @@ -52,11 +54,12 @@
- [getOutOfStore](#getOutOfStore)
- [setDisableNetworkData](#setDisableNetworkData)
- [performOnDeepLinking](#performondeeplinking)
- [logAdRevenue](#logAdRevenue) - Since 6.15.1


---

##### <a id="appsflyer-options"> **`AppsflyerSdk(Map options)`**
##### <a id="appsflyer-options"> **`AppsflyerSdk(Map options)`**

| parameter | type | description |
| --------- | ----- | ----------------- |
Expand Down Expand Up @@ -116,6 +119,42 @@ Once `AppsflyerSdk` object is created, you can call `initSdk` method.

---

##### <a id="AdRevenueData"> **`AdRevenueData`**

| parameter | type | description |
| --------- | ------------------ | ----------------- |
| `monetizationNetwork` | `String` | |
| `mediationNetwork` | `String` | value must be taken from `AFMediationNetwork` |
| `currencyIso4217Code` | `String` | |
| `revenue` | `double` | |
| `additionalParameters` | `Map<String, dynamic>?` | |

---

##### <a id="AFMediationNetwork"> **`AFMediationNetwork`**
an enumeration that includes the supported mediation networks by AppsFlyer.


| networks |
| -------- |
| ironSource
applovinMax
googleAdMob
fyber
appodeal
admost
topon
tradplus
yandex
chartboost
unity
toponPte
customMediation
directMonetizationNetwork |

---


##### <a id="initSdk"> **`initSdk({bool registerConversionDataCallback, bool registerOnAppOpenAttributionCallback}) async` (Changed in 1.2.2)**

initialize the SDK, using the options initialized from the constructor|
Expand Down Expand Up @@ -561,7 +600,7 @@ This call matches the following payload structure:

1. First define the Onelink ID (find it in the AppsFlyer dashboard in the onelink section:

**`Future<void> setAppInviteOneLinkID(String oneLinkID, Function callback)`**
**`Future<void> setAppInviteOneLinkID(String oneLinkID, Function callback)`**

2. Set the AppsFlyerInviteLinkParams class to set the query params in the user invite link:

Expand All @@ -579,7 +618,7 @@ class AppsFlyerInviteLinkParams {

3. Call the generateInviteLink API to generate the user invite link. Use the success and error callbacks for handling.

**`void generateInviteLink(AppsFlyerInviteLinkParams parameters, Function success, Function error)`**
**`void generateInviteLink(AppsFlyerInviteLinkParams parameters, Function success, Function error)`**


_Example:_
Expand Down Expand Up @@ -653,7 +692,7 @@ appsFlyerSdk.setCurrentDeviceLanguage("en");
---
**<a id="setSharingFilterForPartners"> `void setSharingFilterForPartners(List<String> partners)`**

`setSharingFilter` & `setSharingFilterForAllPartners` APIs were deprecated!
`setSharingFilter` & `setSharingFilterForAllPartners` APIs were deprecated!

Use `setSharingFilterForPartners` instead.

Expand All @@ -672,9 +711,9 @@ appsFlyerSdk.setSharingFilterForPartners(['googleadwords_int', 'all']);
---
**<a id="setOneLinkCustomDomain"> `void setOneLinkCustomDomain(List<String> brandDomains)`**

Use this API in order to set branded domains.
Use this API in order to set branded domains.

Find more information in the [following article on branded domains](https://support.appsflyer.com/hc/en-us/articles/360002329137-Implementing-Branded-Links).
Find more information in the [following article on branded domains](https://support.appsflyer.com/hc/en-us/articles/360002329137-Implementing-Branded-Links).

_Example:_
```dart
Expand Down Expand Up @@ -823,3 +862,53 @@ Note:<br>This API will trigger the `appsflyerSdk.onDeepLink` callback. In the fo
_appsflyerSdk.startSDK();
}
```

---

### **<a id="logAdRevenue"> `void logAdRevenue(AdRevenueData adRevenueData)`**

The logAdRevenue API is designed to simplify the process of logging ad revenue events to AppsFlyer from your Flutter application. This API tracks revenue generated from advertisements, enriching your monetization analytics. Below you will find instructions on how to use this API correctly, along with detailed descriptions and examples for various input scenarios.

### **Usage:**
To use the logAdRevenue method, you must:

1. Prepare an instance of `AdRevenueData` with the required information about the ad revenue event.
1. Call `logAdRevenue` with the `AdRevenueData` instance.

**AdRevenueData Class**
[AdRevenueData](#AdRevenueData) is a data class representing all the relevant information about an ad revenue event:

* `monetizationNetwork`: The source network from which the revenue was generated (e.g., AdMob, Unity Ads).
* `mediationNetwork`: The mediation platform managing the ad (use AFMediationNetwork enum for supported networks).
* `currencyIso4217Code`: The ISO 4217 currency code representing the currency of the revenue amount (e.g., "USD", "EUR").
* `revenue`: The amount of revenue generated from the ad.
* `additionalParameters`: Additional parameters related to the ad revenue event (optional).


**AFMediationNetwork Enum**
[AFMediationNetwork](#AFMediationNetwork) is an enumeration that includes the supported mediation networks by AppsFlyer. It's important to use this enum to ensure you provide a valid network identifier to the logAdRevenue API.

### Example:
```dart
// Instantiate AdRevenueData with the ad revenue details.
AdRevenueData adRevenueData = AdRevenueData(
monetizationNetwork: "GoogleAdMob", // Replace with your actual monetization network.
mediationNetwork: AFMediationNetwork.applovinMax.value, // Use the value from the enum.
currencyIso4217Code: "USD",
revenue: 1.23,
additionalParameters: {
// Optional additional parameters can be added here. This is an example, can be discard if not needed.
'adUnitId': 'ca-app-pub-XXXX/YYYY',
'ad_network_click_id': '12345'
}
);
// Log the ad revenue event.
logAdRevenue(adRevenueData);
```

**Additional Points**
* Mediation network input must be from the provided [AFMediationNetwork](#AFMediationNetwork)
enum to ensure proper processing by AppsFlyer. For instance, use `AFMediationNetwork.googleAdMob.value` to denote Google AdMob as the Mediation Network.
* The `additionalParameters` map is optional. Use it to pass any extra information you have regarding the ad revenue event; this information could be useful for more refined analytics.
* Make sure the `currencyIso4217Code` adheres to the appropriate standard. Misconfigured currency code may result in incorrect revenue tracking.
2 changes: 1 addition & 1 deletion ios/Classes/AppsflyerSdkPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@end

// Appsflyer JS objects
#define kAppsFlyerPluginVersion @"6.14.3"
#define kAppsFlyerPluginVersion @"6.15.1"
#define afDevKey @"afDevKey"
#define afAppId @"afAppId"
#define afIsDebug @"isDebug"
Expand Down
Loading

0 comments on commit 6213341

Please sign in to comment.