Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions example/lib/home_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ import 'utils.dart';
class HomeContainer extends StatefulWidget {
final Map onData;
final Future<bool?> Function(String, Map) logEvent;
final void Function() logAdRevenueEvent;
Object deepLinkData;

HomeContainer({
required this.onData,
required this.deepLinkData,
required this.logEvent,
required this.logAdRevenueEvent,
});

@override
Expand Down Expand Up @@ -136,6 +138,20 @@ class _HomeContainerState extends State<HomeContainer> {
),
),
),
ElevatedButton(
onPressed: () {
widget.logAdRevenueEvent();
},
child: Text("Trigger AdRevenue Event"),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
textStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
],
),
)
Expand Down
32 changes: 25 additions & 7 deletions example/lib/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class MainPageState extends State<MainPage> {
onData: _gcd,
deepLinkData: _deepLinkData,
logEvent: logEvent,
logAdRevenueEvent: logAdRevenueEvent,
),
),
ElevatedButton(
Expand All @@ -133,7 +134,8 @@ class MainPageState extends State<MainPage> {
showMessage("AppsFlyer SDK initialized successfully.");
},
onError: (int errorCode, String errorMessage) {
showMessage("Error initializing AppsFlyer SDK: Code $errorCode - $errorMessage");
showMessage(
"Error initializing AppsFlyer SDK: Code $errorCode - $errorMessage");
},
);
},
Expand All @@ -158,13 +160,29 @@ class MainPageState extends State<MainPage> {
return logResult;
}

void logAdRevenueEvent() {
try {
Map<String, String> customParams = {
'ad_platform': 'Admob',
'ad_currency': 'USD',
};

AdRevenueData adRevenueData = AdRevenueData(
monetizationNetwork: 'SpongeBob',
mediationNetwork: AFMediationNetwork.googleAdMob.value,
currencyIso4217Code: 'USD',
revenue: 100.3,
additionalParameters: customParams);
_appsflyerSdk.logAdRevenue(adRevenueData);
print("Ad Revenue event logged with no errors");
} catch (e) {
print("Failed to log event: $e");
}
}

void showMessage(String message) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content:
Text(message),
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(message),
));
}
}


20 changes: 10 additions & 10 deletions ios/Classes/AppsflyerSdkPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -255,20 +255,20 @@ - (void)logAdRevenue:(FlutterMethodCall*)call result:(FlutterResult)result {

- (AppsFlyerAdRevenueMediationNetworkType)getEnumValueFromString:(NSString *)mediationNetworkString {
NSDictionary<NSString *, NSNumber *> *stringToEnumMap = @{
@"googleadmob": @(AppsFlyerAdRevenueMediationNetworkTypeGoogleAdMob),
@"google_admob": @(AppsFlyerAdRevenueMediationNetworkTypeGoogleAdMob),
@"ironsource": @(AppsFlyerAdRevenueMediationNetworkTypeIronSource),
@"applovinmax": @(AppsFlyerAdRevenueMediationNetworkTypeApplovinMax),
@"applovin_max": @(AppsFlyerAdRevenueMediationNetworkTypeApplovinMax),
@"fyber": @(AppsFlyerAdRevenueMediationNetworkTypeFyber),
@"appodeal": @(AppsFlyerAdRevenueMediationNetworkTypeAppodeal),
@"Admost": @(AppsFlyerAdRevenueMediationNetworkTypeAdmost),
@"Topon": @(AppsFlyerAdRevenueMediationNetworkTypeTopon),
@"Tradplus": @(AppsFlyerAdRevenueMediationNetworkTypeTradplus),
@"Yandex": @(AppsFlyerAdRevenueMediationNetworkTypeYandex),
@"admost": @(AppsFlyerAdRevenueMediationNetworkTypeAdmost),
@"topon": @(AppsFlyerAdRevenueMediationNetworkTypeTopon),
@"tradplus": @(AppsFlyerAdRevenueMediationNetworkTypeTradplus),
@"yandex": @(AppsFlyerAdRevenueMediationNetworkTypeYandex),
@"chartboost": @(AppsFlyerAdRevenueMediationNetworkTypeChartBoost),
@"Unity": @(AppsFlyerAdRevenueMediationNetworkTypeUnity),
@"toponpte": @(AppsFlyerAdRevenueMediationNetworkTypeToponPte),
@"customMediation": @(AppsFlyerAdRevenueMediationNetworkTypeCustom),
@"directMonetizationNetwork": @(AppsFlyerAdRevenueMediationNetworkTypeDirectMonetization)
@"unity": @(AppsFlyerAdRevenueMediationNetworkTypeUnity),
@"topon_pte": @(AppsFlyerAdRevenueMediationNetworkTypeToponPte),
@"custom_mediation": @(AppsFlyerAdRevenueMediationNetworkTypeCustom),
@"direct_monetization_network": @(AppsFlyerAdRevenueMediationNetworkTypeDirectMonetization)
};

NSNumber *enumValueNumber = stringToEnumMap[mediationNetworkString];
Expand Down
20 changes: 10 additions & 10 deletions lib/src/appsflyer_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,31 @@ enum AFMediationNetwork {
case AFMediationNetwork.ironSource:
return "ironsource";
case AFMediationNetwork.applovinMax:
return "applovinmax";
return "applovin_max";
case AFMediationNetwork.googleAdMob:
return "googleadmob";
return "google_admob";
case AFMediationNetwork.fyber:
return "fyber";
case AFMediationNetwork.appodeal:
return "appodeal";
case AFMediationNetwork.admost:
return "Admost";
return "admost";
case AFMediationNetwork.topon:
return "Topon";
return "topon";
case AFMediationNetwork.tradplus:
return "Tradplus";
return "tradplus";
case AFMediationNetwork.yandex:
return "Yandex";
return "yandex";
case AFMediationNetwork.chartboost:
return "chartboost";
case AFMediationNetwork.unity:
return "Unity";
return "unity";
case AFMediationNetwork.toponPte:
return "toponpte";
return "topon_pte";
case AFMediationNetwork.customMediation:
return "customMediation";
return "custom_mediation";
case AFMediationNetwork.directMonetizationNetwork:
return "directMonetizationNetwork";
return "direct_monetization_network";
}
}
}