Skip to content

Commit 6213341

Browse files
authored
Merge pull request #338 from AppsFlyerSDK/releases/6.x.x/6.15.x/6.15.1-rc1
Releases/6.x.x/6.15.x/6.15.1 rc1
2 parents 3272d7e + 82764a4 commit 6213341

File tree

14 files changed

+345
-29
lines changed

14 files changed

+345
-29
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Versions
2+
## 6.15.1
3+
- Implementation of the new logAdRevenue API for iOS and Android
4+
- Documentation update for the new logAdRevenue API
5+
- Update iOS version to 6.15.1
6+
- Update Android version to 6.15.1
27
## 6.14.3
38
- Fixed mapOptions issue with manualStart
49
- Inherit Privacy Manifest from the native iOS SDK via Cocoapods

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

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

15-
- Android AppsFlyer SDK **v6.14.0**
16-
- iOS AppsFlyer SDK **v6.14.3**
15+
- Android AppsFlyer SDK **v6.15.1**
16+
- iOS AppsFlyer SDK **v6.15.1**
1717

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

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ android {
3131
dependencies {
3232
implementation fileTree(dir: 'libs', include: ['*.jar'])
3333
implementation 'androidx.appcompat:appcompat:1.0.0'
34-
implementation 'com.appsflyer:af-android-sdk:6.14.0'
34+
implementation 'com.appsflyer:af-android-sdk:6.15.1'
3535
implementation 'com.android.installreferrer:installreferrer:2.1'
3636
}

android/src/main/java/com/appsflyer/appsflyersdk/AppsFlyerConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.appsflyer.appsflyersdk;
22

33
public class AppsFlyerConstants {
4-
final static String PLUGIN_VERSION = "6.14.3";
4+
final static String PLUGIN_VERSION = "6.15.1";
55
final static String AF_APP_INVITE_ONE_LINK = "appInviteOneLink";
66
final static String AF_HOST_PREFIX = "hostPrefix";
77
final static String AF_HOST_NAME = "hostName";

android/src/main/java/com/appsflyer/appsflyersdk/AppsflyerSdkPlugin.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
import android.os.Looper;
1010
import android.util.Log;
1111

12+
import com.appsflyer.AFAdRevenueData;
1213
import com.appsflyer.AFLogger;
1314
import com.appsflyer.AppsFlyerConsent;
1415
import com.appsflyer.AppsFlyerConversionListener;
1516
import com.appsflyer.AppsFlyerInAppPurchaseValidatorListener;
1617
import com.appsflyer.AppsFlyerLib;
1718
import com.appsflyer.AppsFlyerProperties;
19+
import com.appsflyer.MediationNetwork;
1820
import com.appsflyer.deeplink.DeepLinkListener;
1921
import com.appsflyer.deeplink.DeepLinkResult;
2022
import com.appsflyer.share.CrossPromotionHelper;
@@ -344,6 +346,9 @@ public void onMethodCall(MethodCall call, Result result) {
344346
case "addPushNotificationDeepLinkPath":
345347
addPushNotificationDeepLinkPath(call, result);
346348
break;
349+
case "logAdRevenue":
350+
logAdRevenue(call, result);
351+
break;
347352
default:
348353
result.notImplemented();
349354
break;
@@ -954,6 +959,57 @@ private void logEvent(MethodCall call, MethodChannel.Result result) {
954959
result.success(true);
955960
}
956961

962+
private void logAdRevenue(MethodCall call, Result result) {
963+
try {
964+
String monetizationNetwork = requireNonNullArgument(call, "monetizationNetwork");
965+
String currencyIso4217Code = requireNonNullArgument(call, "currencyIso4217Code");
966+
double revenue = requireNonNullArgument(call,"revenue");
967+
String mediationNetworkString = requireNonNullArgument(call,"mediationNetwork");
968+
969+
MediationNetwork mediationNetwork = MediationNetwork.valueOf(mediationNetworkString.toUpperCase());
970+
971+
// No null check for additionalParameters since it's acceptable for it to be null (optional data)
972+
Map<String, Object> additionalParameters = call.argument("additionalParameters");
973+
974+
AFAdRevenueData adRevenueData = new AFAdRevenueData(
975+
monetizationNetwork,
976+
mediationNetwork,
977+
currencyIso4217Code,
978+
revenue
979+
);
980+
981+
AppsFlyerLib.getInstance().logAdRevenue(adRevenueData, additionalParameters);
982+
result.success(true);
983+
984+
} catch (IllegalArgumentException e) {
985+
// The IllegalArgumentException could come from either requireNonNullArgument or valueOf methods.
986+
result.error("INVALID_ARGUMENT_PROVIDED", e.getMessage(), null);
987+
}
988+
catch (Throwable t) {
989+
result.error("UNEXPECTED_ERROR", "[logAdRevenue]: An unexpected error occurred: " + t.getMessage(), null);
990+
Log.e("AppsFlyer", "Unexpected exception occurred: [logAdRevenue]", t);
991+
}
992+
}
993+
994+
/**
995+
* Utility method to ensure that an argument with the specified name is not null.
996+
* If the argument is null, this method will throw an IllegalArgumentException.
997+
* The calling method can then terminate immediately without further processing.
998+
*
999+
* @param call The MethodCall from Flutter, containing all the arguments.
1000+
* @param argumentName The name of the argument expected in the MethodCall.
1001+
* @param <T> The type of the argument being checked for nullity.
1002+
* @return The argument value if it is not null; throw IllegalArgumentException otherwise.
1003+
*/
1004+
private <T> T requireNonNullArgument(MethodCall call, String argumentName) throws IllegalArgumentException {
1005+
T argument = call.argument(argumentName);
1006+
if (argument == null) {
1007+
Log.e("AppsFlyer", "Exception occurred when trying to: " + call.method + "->" + argumentName + " must not be null");
1008+
throw new IllegalArgumentException("[" + call.method + "]: " + argumentName + " must not be null");
1009+
}
1010+
return argument;
1011+
}
1012+
9571013
//RD-65582
9581014
private void sendCachedCallbacksToDart() {
9591015
if (cachedDeepLinkResult != null) {

doc/API.md

Lines changed: 95 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
## Types
66
- [AppsFlyerOptions](#appsflyer-options)
7+
- [AdRevenueData](#AdRevenueData)
8+
- [AFMediationNetwork](#AFMediationNetwork)
79

810
## Methods
911
- [initSdk](#initSdk)
@@ -52,11 +54,12 @@
5254
- [getOutOfStore](#getOutOfStore)
5355
- [setDisableNetworkData](#setDisableNetworkData)
5456
- [performOnDeepLinking](#performondeeplinking)
57+
- [logAdRevenue](#logAdRevenue) - Since 6.15.1
5558

5659

5760
---
5861

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

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

117120
---
118121

122+
##### <a id="AdRevenueData"> **`AdRevenueData`**
123+
124+
| parameter | type | description |
125+
| --------- | ------------------ | ----------------- |
126+
| `monetizationNetwork` | `String` | |
127+
| `mediationNetwork` | `String` | value must be taken from `AFMediationNetwork` |
128+
| `currencyIso4217Code` | `String` | |
129+
| `revenue` | `double` | |
130+
| `additionalParameters` | `Map<String, dynamic>?` | |
131+
132+
---
133+
134+
##### <a id="AFMediationNetwork"> **`AFMediationNetwork`**
135+
an enumeration that includes the supported mediation networks by AppsFlyer.
136+
137+
138+
| networks |
139+
| -------- |
140+
| ironSource
141+
applovinMax
142+
googleAdMob
143+
fyber
144+
appodeal
145+
admost
146+
topon
147+
tradplus
148+
yandex
149+
chartboost
150+
unity
151+
toponPte
152+
customMediation
153+
directMonetizationNetwork |
154+
155+
---
156+
157+
119158
##### <a id="initSdk"> **`initSdk({bool registerConversionDataCallback, bool registerOnAppOpenAttributionCallback}) async` (Changed in 1.2.2)**
120159

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

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

564-
**`Future<void> setAppInviteOneLinkID(String oneLinkID, Function callback)`**
603+
**`Future<void> setAppInviteOneLinkID(String oneLinkID, Function callback)`**
565604

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

@@ -579,7 +618,7 @@ class AppsFlyerInviteLinkParams {
579618

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

582-
**`void generateInviteLink(AppsFlyerInviteLinkParams parameters, Function success, Function error)`**
621+
**`void generateInviteLink(AppsFlyerInviteLinkParams parameters, Function success, Function error)`**
583622

584623

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

656-
`setSharingFilter` & `setSharingFilterForAllPartners` APIs were deprecated!
695+
`setSharingFilter` & `setSharingFilterForAllPartners` APIs were deprecated!
657696

658697
Use `setSharingFilterForPartners` instead.
659698

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

675-
Use this API in order to set branded domains.
714+
Use this API in order to set branded domains.
676715

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

679718
_Example:_
680719
```dart
@@ -823,3 +862,53 @@ Note:<br>This API will trigger the `appsflyerSdk.onDeepLink` callback. In the fo
823862
_appsflyerSdk.startSDK();
824863
}
825864
```
865+
866+
---
867+
868+
### **<a id="logAdRevenue"> `void logAdRevenue(AdRevenueData adRevenueData)`**
869+
870+
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.
871+
872+
### **Usage:**
873+
To use the logAdRevenue method, you must:
874+
875+
1. Prepare an instance of `AdRevenueData` with the required information about the ad revenue event.
876+
1. Call `logAdRevenue` with the `AdRevenueData` instance.
877+
878+
**AdRevenueData Class**
879+
[AdRevenueData](#AdRevenueData) is a data class representing all the relevant information about an ad revenue event:
880+
881+
* `monetizationNetwork`: The source network from which the revenue was generated (e.g., AdMob, Unity Ads).
882+
* `mediationNetwork`: The mediation platform managing the ad (use AFMediationNetwork enum for supported networks).
883+
* `currencyIso4217Code`: The ISO 4217 currency code representing the currency of the revenue amount (e.g., "USD", "EUR").
884+
* `revenue`: The amount of revenue generated from the ad.
885+
* `additionalParameters`: Additional parameters related to the ad revenue event (optional).
886+
887+
888+
**AFMediationNetwork Enum**
889+
[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.
890+
891+
### Example:
892+
```dart
893+
// Instantiate AdRevenueData with the ad revenue details.
894+
AdRevenueData adRevenueData = AdRevenueData(
895+
monetizationNetwork: "GoogleAdMob", // Replace with your actual monetization network.
896+
mediationNetwork: AFMediationNetwork.applovinMax.value, // Use the value from the enum.
897+
currencyIso4217Code: "USD",
898+
revenue: 1.23,
899+
additionalParameters: {
900+
// Optional additional parameters can be added here. This is an example, can be discard if not needed.
901+
'adUnitId': 'ca-app-pub-XXXX/YYYY',
902+
'ad_network_click_id': '12345'
903+
}
904+
);
905+
906+
// Log the ad revenue event.
907+
logAdRevenue(adRevenueData);
908+
```
909+
910+
**Additional Points**
911+
* Mediation network input must be from the provided [AFMediationNetwork](#AFMediationNetwork)
912+
enum to ensure proper processing by AppsFlyer. For instance, use `AFMediationNetwork.googleAdMob.value` to denote Google AdMob as the Mediation Network.
913+
* 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.
914+
* Make sure the `currencyIso4217Code` adheres to the appropriate standard. Misconfigured currency code may result in incorrect revenue tracking.

ios/Classes/AppsflyerSdkPlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@end
1919

2020
// Appsflyer JS objects
21-
#define kAppsFlyerPluginVersion @"6.14.3"
21+
#define kAppsFlyerPluginVersion @"6.15.1"
2222
#define afDevKey @"afDevKey"
2323
#define afAppId @"afAppId"
2424
#define afIsDebug @"isDebug"

0 commit comments

Comments
 (0)