diff --git a/plugin.xml b/plugin.xml
index 054aa3a6..c55bd3d1 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -91,7 +91,7 @@
-
+
diff --git a/src/android/com/appsflyer/cordova/plugin/AppsFlyerConstants.java b/src/android/com/appsflyer/cordova/plugin/AppsFlyerConstants.java
index 0cd7b5e3..f5bdc93c 100644
--- a/src/android/com/appsflyer/cordova/plugin/AppsFlyerConstants.java
+++ b/src/android/com/appsflyer/cordova/plugin/AppsFlyerConstants.java
@@ -6,7 +6,7 @@
public class AppsFlyerConstants {
- final static String PLUGIN_VERSION = "6.14.0";
+ final static String PLUGIN_VERSION = "6.15.0";
final static String NO_DEVKEY_FOUND = "AppsFlyer 'devKey' is missing or empty";
final static String NO_GCM_PROJECT_NUMBER_PROVIDED = "No GCM Project number provided";
final static String SUCCESS = "Success";
diff --git a/src/android/com/appsflyer/cordova/plugin/AppsFlyerPlugin.java b/src/android/com/appsflyer/cordova/plugin/AppsFlyerPlugin.java
index e37358d0..2a6f95f9 100644
--- a/src/android/com/appsflyer/cordova/plugin/AppsFlyerPlugin.java
+++ b/src/android/com/appsflyer/cordova/plugin/AppsFlyerPlugin.java
@@ -176,10 +176,54 @@ public boolean execute(final String action, JSONArray args, CallbackContext call
return setConsentData(args);
} else if ("enableTCFDataCollection".equals(action)) {
return enableTCFDataCollection(args);
+ } else if ("logAdRevenue".equals(action)) {
+ return logAdRevenue(args);
}
return false;
}
+ /**
+ * log AdRevenue event
+ *
+ * @param args - event params
+ * @return true
+ */
+ private boolean logAdRevenue(JSONArray args) {
+ cordova.getThreadPool().execute(() -> {
+ Map additionalParameters = null;
+ try {
+ JSONObject afAdRevenueDataJsonObj = args.getJSONObject(0);
+ String monetizationNetwork = afAdRevenueDataJsonObj.optString("monetizationNetwork", null);
+ String mediationNetwork = afAdRevenueDataJsonObj.optString("mediationNetwork", null);
+ String currencyIso4217Code = afAdRevenueDataJsonObj.optString("currencyIso4217Code", null);
+ double revenue = afAdRevenueDataJsonObj.optDouble("revenue", -1);
+
+ if(args.get(1) != null){
+ JSONObject additionalParametersJson = args.getJSONObject(1);
+ additionalParameters = toObjectMap(additionalParametersJson);
+ }
+
+ if(mediationNetwork != null){
+ MediationNetwork mediationNetworkEnumVal = null;
+ for(MediationNetwork mediationNetworkEnum: MediationNetwork.values()){
+ if(mediationNetworkEnum.name().equals(mediationNetwork)){
+ mediationNetworkEnumVal = MediationNetwork.valueOf(mediationNetwork);
+ }
+ }
+ if(mediationNetworkEnumVal != null){
+ AFAdRevenueData afAdRevenueData = new AFAdRevenueData(monetizationNetwork, mediationNetworkEnumVal, currencyIso4217Code, revenue);
+ AppsFlyerLib.getInstance().logAdRevenue(afAdRevenueData, additionalParameters);
+ }
+ }
+
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ });
+ return true;
+ }
+
+
/**
* set consent data according to GDPR if applies or not.
*
diff --git a/src/android/cordovaAF.gradle b/src/android/cordovaAF.gradle
index 70d1d051..011933b3 100644
--- a/src/android/cordovaAF.gradle
+++ b/src/android/cordovaAF.gradle
@@ -4,7 +4,7 @@ repositories {
dependencies {
implementation 'com.android.installreferrer:installreferrer:2.1'
- implementation 'com.appsflyer:af-android-sdk:6.14.0@aar'
+ implementation 'com.appsflyer:af-android-sdk:6.15.0@aar'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.6.20'
}
diff --git a/src/ios/AppsFlyerPlugin.h b/src/ios/AppsFlyerPlugin.h
index 5eb390a2..dc708fe7 100755
--- a/src/ios/AppsFlyerPlugin.h
+++ b/src/ios/AppsFlyerPlugin.h
@@ -33,6 +33,7 @@
- (void)setCurrentDeviceLanguage:(CDVInvokedUrlCommand*)command;
- (void)setAdditionalData:(CDVInvokedUrlCommand*)command;
- (void)setConsentData:(CDVInvokedUrlCommand*)command;
+- (void)logAdRevenue:(CDVInvokedUrlCommand*)command;
- (void)enableTCFDataCollection:(CDVInvokedUrlCommand*)command;
- (void)setSharingFilter:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
- (void)setSharingFilterForAllPartners:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
diff --git a/src/ios/AppsFlyerPlugin.m b/src/ios/AppsFlyerPlugin.m
index f88ba119..f0879268 100755
--- a/src/ios/AppsFlyerPlugin.m
+++ b/src/ios/AppsFlyerPlugin.m
@@ -96,7 +96,7 @@ - (void)initSdk:(CDVInvokedUrlCommand*)command
}
// Initialize the SDK
- [[AppsFlyerLib shared] setPluginInfoWith:AFSDKPluginCordova pluginVersion:@"6.14.3" additionalParams:nil];
+ [[AppsFlyerLib shared] setPluginInfoWith:AFSDKPluginCordova pluginVersion:@"6.15.0" additionalParams:nil];
[AppsFlyerLib shared].appleAppID = appId;
[AppsFlyerLib shared].appsFlyerDevKey = devKey;
[AppsFlyerLib shared].isDebug = isDebug;
@@ -196,6 +196,50 @@ - (void)setCurrencyCode:(CDVInvokedUrlCommand*)command
[AppsFlyerLib shared].currencyCode = currencyId;
}
+/**
+* log AdRevenue event
+*/
+- (void)logAdRevenue:(CDVInvokedUrlCommand*)command
+{
+ if ([command.arguments count] == 0) {
+ return;
+ }
+ NSDictionary *afAdRevenueDataMap = (NSDictionary*)[command.arguments objectAtIndex: 0];
+
+ id monetizationNetwork = nil;
+ id mediationNetwork = nil;
+ id currencyIso4217Code = nil;
+ id revenue = -1;
+
+ id monetizationNetworkValue = nil;
+ id mediationNetworkValue = nil;
+ id currencyIso4217CodeValue = nil;
+ id revenueValue = -1;
+
+ monetizationNetworkValue = [afAdRevenueDataMap objectForKey:@"monetizationNetwork"];
+ if ([monetizationNetworkValue isKindOfClass:[NSString class]]) {
+ monetizationNetwork = monetizationNetworkValue;
+ }
+
+ mediationNetworkValue = [afAdRevenueDataMap objectForKey:@"mediationNetwork"];
+ if ([mediationNetworkValue isKindOfClass:[NSString class]]) {
+ hasConsentForDataUsage = [(NSNumber*)hasConsentForDataUsageValue boolValue];
+ }
+
+ hasConsentForAdsPersonalizationValue = [consentDataMap objectForKey:@"hasConsentForAdsPersonalization"];
+ if ([hasConsentForAdsPersonalizationValue isKindOfClass:[NSNumber class]]) {
+ hasConsentForAdsPersonalization = [(NSNumber*)hasConsentForAdsPersonalizationValue boolValue];
+ }
+
+ AppsFlyerConsent *consentData = nil;
+ if (isUserSubjectToGDPR) {
+ consentData = [[AppsFlyerConsent alloc] initForGDPRUserWithHasConsentForDataUsage:hasConsentForDataUsage hasConsentForAdsPersonalization:hasConsentForAdsPersonalization];
+ } else {
+ consentData = [[AppsFlyerConsent alloc] initNonGDPRUser];
+ }
+ [[AppsFlyerLib shared] setConsentData:consentData];
+}
+
/**
* Sets new currency code. currencyId: ISO 4217 Currency Codes.
*/
diff --git a/www/appsflyer.js b/www/appsflyer.js
index 2d6fe85b..44aba574 100644
--- a/www/appsflyer.js
+++ b/www/appsflyer.js
@@ -3,6 +3,8 @@ var exec = require('cordova/exec'),
AppsFlyerError = require('./AppsFlyerError');
var callbackMap = {};
+let AFAdRevenueData;
+
if (!window.CustomEvent) {
window.CustomEvent = function (type, config) {
var e = document.createEvent('CustomEvent');
@@ -37,6 +39,45 @@ if (!window.CustomEvent) {
};
})();
+ // AFAdRevenueData object with MediationNetwork enum
+ global.AFAdRevenueData = (function() {
+ const MediationNetwork = {
+ IRONSOURCE:"ironsource",
+ APPLOVIN_MAX:"applovinmax",
+ GOOGLE_ADMOB:"googleadmob",
+ FYBER:"fyber",
+ APPODEAL:"appodeal",
+ ADMOST:"Admost",
+ TOPON:"Topon",
+ TRADPLUS:"Tradplus",
+ YANDEX:"Yandex",
+ CHARTBOOST:"chartboost",
+ UNITY:"Unity",
+ TOPON_PTE:"toponpte",
+ CUSTOM_MEDIATION:"customMediation",
+ DIRECT_MONETIZATION_NETWORK:"directMonetizationNetwork"
+ };
+
+ function AFAdRevenueData(monetizationNetwork, mediationNetwork, currencyIso4217Code, revenue) {
+ if (!Object.values(MediationNetwork).includes(mediationNetwork)) {
+ throw new Error("Invalid enum value for 'mediationNetwork'.");
+ }
+ this.monetizationNetwork = monetizationNetwork;
+ this.mediationNetwork = mediationNetwork;
+ this.currencyIso4217Code = currencyIso4217Code;
+ this.revenue = revenue;
+ }
+
+ return AFAdRevenueData; // Expose the constructor directly
+ })();
+
+ function validateAFAdRevenueData(afAdRevenueData) {
+ if (!(afAdRevenueData instanceof AFAdRevenueData)) {
+ throw new Error("Invalid AFAdRevenueData object.");
+ }
+ return afAdRevenueData;
+ }
+
/**
* initialize the SDK.
* args: SDK configuration
@@ -109,6 +150,19 @@ if (!window.CustomEvent) {
exec(null, null, 'AppsFlyerPlugin', 'setCurrencyCode', [currencyId]);
};
+ /**
+ * Public API - logAdRevenue function
+ */
+ AppsFlyer.prototype.logAdRevenue = function(afAdRevenueData, additionalParameters) {
+ argscheck.checkArgs('S', 'AppsFlyer.logAdRevenue', arguments);
+
+ // Validate AFAdRevenueData before logging
+ const validatedAfAdRevenueData = validateAFAdRevenueData(afAdRevenueData);
+
+ // Call the 'logAdRevenue' API method with the validated data
+ exec(null, null, 'AppsFlyerPlugin', 'logAdRevenue', [validatedAfAdRevenueData, additionalParameters]);
+ };
+
/**
* Setting your own Custom ID enables you to cross-reference your own unique ID with AppsFlyer’s user ID and the other devices’ IDs.
*/