Skip to content

Commit

Permalink
Update to 6.15.3
Browse files Browse the repository at this point in the history
* Implement logAdRevenueAPI for iOS
  • Loading branch information
af-obodovskyi committed Oct 4, 2024
1 parent 69868b5 commit 7640476
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 10 deletions.
41 changes: 41 additions & 0 deletions Classes/AppsFlyer/AFXAdRevenueData.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// AFXAdRevenueData.cpp
// MyGame
//
// Created by ivan.obodovskyi on 04.10.2024.
//

#include <stdio.h>
#include "AFXAdRevenueData.h"

// Constructor definition
AFXAdRevenueData::AFXAdRevenueData(const std::string& monetizationNetwork,
AppsFlyerXAdRevenueMediationNetworkType mediationNetwork,
const std::string& currencyIso4217Code,
double eventRevenue)
: monetizationNetwork(monetizationNetwork),
mediationNetwork(mediationNetwork),
currencyIso4217Code(currencyIso4217Code),
eventRevenue(eventRevenue) {
}

// Getters implementation
std::string AFXAdRevenueData::getMonetizationNetwork() const {
return monetizationNetwork;
}

AppsFlyerXAdRevenueMediationNetworkType AFXAdRevenueData::getMediationNetwork() const {
return mediationNetwork;
}

std::string AFXAdRevenueData::getCurrencyIso4217Code() const {
return currencyIso4217Code;
}

double AFXAdRevenueData::getEventRevenue() const {
return eventRevenue;
}

int convertMeditationType(AppsFlyerXAdRevenueMediationNetworkType a) {
return static_cast<int>(static_cast<int>(a));
}
76 changes: 76 additions & 0 deletions Classes/AppsFlyer/AFXAdRevenueData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// AFXAdRevenueData.h
// MyGame
//
// Created by ivan.obodovskyi on 04.10.2024.
//

#include <string>

#ifndef AFXAdRevenueData_h
#define AFXAdRevenueData_h

enum class AppsFlyerXAdRevenueMediationNetworkType {
GoogleAdMob = 1,
IronSource = 2,
ApplovinMax = 3,
Fyber = 4,
Appodeal = 5,
Admost = 6,
Topon = 7,
Tradplus = 8,
Yandex = 9,
ChartBoost = 10,
Unity = 11,
ToponPte = 12,
Custom = 13,
DirectMonetization = 14
};

#define kAppsFlyerAdRevenueMonetizationNetwork @"monetization_network"
#define kAppsFlyerAdRevenueMediationNetwork @"mediation_network"
#define kAppsFlyerAdRevenueEventRevenue @"event_revenue"
#define kAppsFlyerAdRevenueEventRevenueCurrency @"event_revenue_currency"
#define kAppsFlyerAdRevenueCustomParameters @"custom_parameters"
#define kAFADRWrapperTypeGeneric @"adrevenue_sdk"

//Pre-defined keys for non-mandatory dictionary

//Code ISO 3166-1 format
#define kAppsFlyerAdRevenueCountry @"country"

//ID of the ad unit for the impression
#define kAppsFlyerAdRevenueAdUnit @"ad_unit"

//Format of the ad
#define kAppsFlyerAdRevenueAdType @"ad_type"

//ID of the ad placement for the impression
#define kAppsFlyerAdRevenuePlacement @"placement"


class AFXAdRevenueData {
public:
// Constructor with initialization parameters
AFXAdRevenueData(const std::string& monetizationNetwork,
AppsFlyerXAdRevenueMediationNetworkType mediationNetwork,
const std::string& currencyIso4217Code,
double eventRevenue);

// Getter functions for each property
std::string getMonetizationNetwork() const;
AppsFlyerXAdRevenueMediationNetworkType getMediationNetwork() const;
std::string getCurrencyIso4217Code() const;
double getEventRevenue() const;
int convertMeditationType(AppsFlyerXAdRevenueMediationNetworkType a);

private:
// Private member variables
std::string monetizationNetwork;
AppsFlyerXAdRevenueMediationNetworkType mediationNetwork;
std::string currencyIso4217Code;
double eventRevenue;
};


#endif /* AFXAdRevenueData_h */
8 changes: 8 additions & 0 deletions Classes/AppsFlyer/AppsFlyerX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ void AppsFlyerX::validateAndLogInAppPurchase(const std::string& publicKey,
#endif
}

void AppsFlyerX::logAdRevenue(AFXAdRevenueData adRevenueData, cocos2d::ValueMap additionalParameters) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// Android implementation
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
AppsFlyerXApple::logAdRevenue(adRevenueData, additionalParameters);
#endif
}

void AppsFlyerX::validateAndLogInAppPurchase(AFSDKXPurchaseDetails &details, cocos2d::ValueMap params, std::function<void(AFSDKXValidateAndLogResult)> completionHandler) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// Android implementation
Expand Down
3 changes: 3 additions & 0 deletions Classes/AppsFlyer/AppsFlyerX.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "AppsFlyerXDeepLinkResult.h"
#include "AppsFlyerXConsent.cpp"
#include "AFSDKXPurchaseDetails.h"
#include "AFXAdRevenueData.h"


class AppsFlyerX {
Expand Down Expand Up @@ -75,6 +76,8 @@ class AppsFlyerX {

static void logEvent(const std::string& eventName, cocos2d::ValueMap values);

static void logAdRevenue(AFXAdRevenueData adRevenueData, cocos2d::ValueMap additionalParameters);

static void validateAndLogInAppPurchase(const std::string& productIdentifier,
const std::string& price,
const std::string& currency,
Expand Down
12 changes: 3 additions & 9 deletions Classes/AppsFlyer/AppsFlyerXApple.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,28 +97,22 @@ class AppsFlyerXApple {
cocos2d::ValueMap params,
std::function<void(AFSDKXValidateAndLogResult)> completionHandler);

static void logAdRevenue(AFXAdRevenueData adRevenueData, cocos2d::ValueMap additionalParameters);

static void logLocation(double longitude, double latitude);

static std::string getAppsFlyerUID();


static void handleOpenURL(const std::string& url, const std::string& sourceApplication);

static void handleOpenURL(std::string url, std::string sourceApplication, void* annotation);

static void handleOpenURL(std::string url, cocos2d::ValueMap options);

/*
- (BOOL) continueUserActivity:(NSUserActivity *) userActivity restorationHandler:(void (^)(NSArray *))restorationHandler NS_AVAILABLE_IOS(9_0);
- (void) didUpdateUserActivity:(NSUserActivity *)userActivity NS_AVAILABLE_IOS(9_0);
*/

static void handlePushNotification(cocos2d::ValueMap pushPayload);

static void registerUninstall(void* deviceToken, unsigned long length);

// static std::string getSDKVersion();

static void remoteDebuggingCallWithData(const std::string& data);

static void setHost(const std::string& host);
Expand All @@ -130,7 +124,7 @@ class AppsFlyerXApple {
static void stop(bool stop);


// Delegates methods proxy
// MARK: - AppsFlyerLib delegate proxy methods
static void setOnConversionDataReceived(void(*callback)(cocos2d::ValueMap installData));
static void setOnConversionDataRequestFailure(void(*callback)(cocos2d::ValueMap error));
static void setOnAppOpenAttribution(void(*callback)(cocos2d::ValueMap attributionData));
Expand Down
15 changes: 15 additions & 0 deletions Classes/AppsFlyer/AppsFlyerXApple.mm
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,25 @@
transactionId:transactionId];

[[AppsFlyerLib shared] validateAndLogInAppPurchase:afPurchaseDetails extraEventValues:lParams completionHandler:^(AFSDKValidateAndLogResult * _Nullable result) {
// TODO: - add result to completionHandler
NSLog(@"[ValidateAndLog] Result: %@", result);
}];
}

void AppsFlyerXApple::logAdRevenue(AFXAdRevenueData adRevenueData,
cocos2d::ValueMap additionalParameters) {
NSDictionary *lParams = AppsFlyerXAppleHelper::valueMap2nsDictionary(additionalParameters);

NSString * monetizationNetwork = [NSString stringWithUTF8String:adRevenueData.getMonetizationNetwork().c_str()];
AppsFlyerAdRevenueMediationNetworkType mediationNetwork = static_cast<AppsFlyerAdRevenueMediationNetworkType>(adRevenueData.getMediationNetwork());
NSString * currencyIso4217Code = [NSString stringWithUTF8String:adRevenueData.getCurrencyIso4217Code().c_str()];
NSNumber *eventRevenue = [NSNumber numberWithDouble:adRevenueData.getEventRevenue()];

AFAdRevenueData *appsflyerAdRevenueData = [[AFAdRevenueData alloc] initWithMonetizationNetwork:monetizationNetwork mediationNetwork:mediationNetwork currencyIso4217Code:currencyIso4217Code eventRevenue:eventRevenue];

[[AppsFlyerLib shared] logAdRevenue:appsflyerAdRevenueData additionalParameters:lParams];
}

void AppsFlyerXApple::logLocation(double longitude, double latitude) {
[[AppsFlyerLib shared] logLocation:longitude latitude:latitude];
}
Expand Down
2 changes: 1 addition & 1 deletion proj.ios_mac/ios/AppController.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
****************************************************************************/

#import <UIKit/UIKit.h>
#import "AppsFlyerLib.h"
#import "AppsFlyer/libAppsFlyer/AppsFlyerLib.h"

@class RootViewController;

Expand Down

0 comments on commit 7640476

Please sign in to comment.