Skip to content

Commit

Permalink
Update Strict AppsFlyer Source files
Browse files Browse the repository at this point in the history
  • Loading branch information
af-obodovskyi committed Oct 4, 2024
1 parent 120056c commit c8accc8
Show file tree
Hide file tree
Showing 19 changed files with 645 additions and 47 deletions.
51 changes: 51 additions & 0 deletions Classes/Strict/AppsFlyer/AFSDKXPurchaseDetails.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// AFSDKXPurchaseDetails.cpp
// MyGame
//
// Created by ivan.obodovskyi on 02.10.2024.
//

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

AFSDKXPurchaseDetails::AFSDKXPurchaseDetails(const std::string &productId,
const std::string &price,
const std::string &currency,
const std::string &transactionId)
: productId_(productId),
price_(price),
currency_(currency),
transactionId_(transactionId) {
}

std::string AFSDKXPurchaseDetails::getProductId() const {
return productId_;
}

void AFSDKXPurchaseDetails::setProductId(const std::string &productId) {
productId_ = productId;
}

std::string AFSDKXPurchaseDetails::getPrice() const {
return price_;
}

void AFSDKXPurchaseDetails::setPrice(const std::string &price) {
price_ = price;
}

std::string AFSDKXPurchaseDetails::getCurrency() const {
return currency_;
}

void AFSDKXPurchaseDetails::setCurrency(const std::string &currency) {
currency_ = currency;
}

std::string AFSDKXPurchaseDetails::getTransactionId() const {
return transactionId_;
}

void AFSDKXPurchaseDetails::setTransactionId(const std::string &transactionId) {
transactionId_ = transactionId;
}
54 changes: 54 additions & 0 deletions Classes/Strict/AppsFlyer/AFSDKXPurchaseDetails.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// AFSDKXPurchaseDetails.h
// MyGame
//
// Created by ivan.obodovskyi on 02.10.2024.
//

#ifndef AFSDKXPurchaseDetails_h
#define AFSDKXPurchaseDetails_h

#include <string>
#include "cocos2d.h"
#include "AFSDKXValidateAndLogResult.h"


class AFSDKXPurchaseDetails {
public:
// Deleted default constructor to prevent usage.
AFSDKXPurchaseDetails() = delete;

// Constructor with parameters to initialize the properties.
AFSDKXPurchaseDetails(const std::string &productId,
const std::string &price,
const std::string &currency,
const std::string &transactionId);

// Default destructor.
virtual ~AFSDKXPurchaseDetails() = default;

// Public assignment and copy constructors
AFSDKXPurchaseDetails(const AFSDKXPurchaseDetails &) = default;
AFSDKXPurchaseDetails &operator=(const AFSDKXPurchaseDetails &) = default;

// Getters and setters for private member variables.
std::string getProductId() const;
void setProductId(const std::string &productId);

std::string getPrice() const;
void setPrice(const std::string &price);

std::string getCurrency() const;
void setCurrency(const std::string &currency);

std::string getTransactionId() const;
void setTransactionId(const std::string &transactionId);

private:
// Private member variables.
std::string productId_;
std::string price_;
std::string currency_;
std::string transactionId_;
};
#endif /* AFSDKXPurchaseDetails_h */
35 changes: 35 additions & 0 deletions Classes/Strict/AppsFlyer/AFSDKXValidateAndLogResult.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// AFSDKXValidateAndLogResult.cpp
// MyGame
//
// Created by ivan.obodovskyi on 03.10.2024.
//

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

// Constructor implementation.
AFSDKXValidateAndLogResult::AFSDKXValidateAndLogResult(
AFSDKXValidateAndLogStatus status,
const cocos2d::ValueMap& result,
const cocos2d::ValueMap& errorData,
const std::shared_ptr<Error>& error)
: status_(status), result_(result), errorData_(errorData), error_(error) {
}

// Getter methods implementation.
AFSDKXValidateAndLogStatus AFSDKXValidateAndLogResult::getStatus() const {
return status_;
}

cocos2d::ValueMap AFSDKXValidateAndLogResult::getResult() const {
return result_;
}

cocos2d::ValueMap AFSDKXValidateAndLogResult::getErrorData() const {
return errorData_;
}

std::shared_ptr<Error> AFSDKXValidateAndLogResult::getError() const {
return error_;
}
52 changes: 52 additions & 0 deletions Classes/Strict/AppsFlyer/AFSDKXValidateAndLogResult.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// AFSDKXValidateAndLogResult.h
// MyGame
//
// Created by ivan.obodovskyi on 03.10.2024.
//

#ifndef AFSDKXValidateAndLogResult_h
#define AFSDKXValidateAndLogResult_h

#include <cocos2d.h>
#include <unordered_map>
#include <string>
#include <memory>
#include <optional>

// Assuming an error class similar to NSError exists in your C++ code.
class Error;

// Enum to represent validation status
enum class AFSDKXValidateAndLogStatus {
Success,
Failure,
Error
};

class AFSDKXValidateAndLogResult {
public:
// Deleting default constructor to prevent usage.
AFSDKXValidateAndLogResult() = delete;

// Constructor with initialization list.
AFSDKXValidateAndLogResult(AFSDKXValidateAndLogStatus status,
const cocos2d::ValueMap& result,
const cocos2d::ValueMap& errorData,
const std::shared_ptr<Error>& error);

// Getter methods
AFSDKXValidateAndLogStatus getStatus() const;
cocos2d::ValueMap getResult() const;
cocos2d::ValueMap getErrorData() const;
std::shared_ptr<Error> getError() const;

private:
// Member variables.
AFSDKXValidateAndLogStatus status_;
cocos2d::ValueMap result_;
cocos2d::ValueMap errorData_;
std::shared_ptr<Error> error_;
};

#endif /* AFSDKXValidateAndLogResult_h */
41 changes: 41 additions & 0 deletions Classes/Strict/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/Strict/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 */
2 changes: 1 addition & 1 deletion Classes/Strict/AppsFlyer/AppsFlyerX+AppController.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by AndreyG-AF on 10/17/17.
//

#import "AppController.h"


@interface AppController (AppsFlyerX)

Expand Down
2 changes: 1 addition & 1 deletion Classes/Strict/AppsFlyer/AppsFlyerX+AppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import "AppsFlyerX+AppController.h"
#import <objc/runtime.h>
#import "AppsFlyerLib.h"
#import "AppsFlyer/libAppsFlyer/AppsFlyerLib.h"

@implementation AppController (AppsFlyerX)

Expand Down
47 changes: 47 additions & 0 deletions Classes/Strict/AppsFlyer/AppsFlyerX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,28 @@
#include "AppsFlyerXApple.h"
#endif

bool AppsFlyerX::manualStart = false;

void AppsFlyerX::setManualStart(bool isManualStart) {
manualStart = isManualStart;
}

//static void enableTCFDataCollection(bool shouldCollectConsentData);
void AppsFlyerX::enableTCFDataCollection(bool shouldCollectConsentData) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
AppsFlyerXAndroid::enableTCFDataCollection(shouldCollectConsentData);
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
AppsFlyerXApple::enableTCFDataCollection(shouldCollectConsentData);
#endif
}

void AppsFlyerX::setConsentData(const AppsFlyerXConsent& consentData){
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
AppsFlyerXAndroid::setConsentData(consentData);
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
AppsFlyerXApple::setConsentData(consentData);
#endif
}

void AppsFlyerX::setCustomerUserID(const std::string& customerUserID) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
Expand Down Expand Up @@ -310,6 +332,22 @@ 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
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
AppsFlyerXApple::validateAndLogInAppPurchase(details, params, completionHandler);
#endif
}


std::string AppsFlyerX::getAppsFlyerUID() {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
Expand Down Expand Up @@ -595,3 +633,12 @@ void AppsFlyerX::generateUserInviteLink(cocos2d::ValueMap parameters, std::funct
AppsFlyerXApple::generateUserInviteLink(parameters, callback);
#endif
}

void AppsFlyerX::setDisableNetworkData(bool disable){
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
AppsFlyerXAndroid::setDisableNetworkData(disable);
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
//not supported for iOS
CCLOGWARN("%s", "setDisableNetworkData is not supported for iOS");
#endif
}
Loading

0 comments on commit c8accc8

Please sign in to comment.