Skip to content

Commit

Permalink
v6.15.3 updates
Browse files Browse the repository at this point in the history
* iOS updates for 6.15.3 validateAndLog public API
* Fix image assets file in the sample app iOS project
TBD - update logAdRevenue
  • Loading branch information
af-obodovskyi committed Oct 4, 2024
1 parent b565192 commit 69868b5
Show file tree
Hide file tree
Showing 57 changed files with 1,008 additions and 88 deletions.
6 changes: 6 additions & 0 deletions AppIcon.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
15 changes: 15 additions & 0 deletions AppIcon.xcassets/Icon-180.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Icon-180.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "original"
}
}
Binary file added AppIcon.xcassets/Icon-180.imageset/Icon-180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 18 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ project(${APP_NAME})
set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cocos2d)
set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/)

# Print the values
message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
message(STATUS "COCOS2DX_ROOT_PATH: ${COCOS2DX_ROOT_PATH}")
message(STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
message(STATUS "COCOS2DX_ROOT_PATH: ${COCOS2DX_ROOT_PATH}")
message(STATUS "Is ANDROID?: ${ANDROID}")

include(CocosBuildSet)
add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos ${ENGINE_BINARY_PATH}/cocos/core)

Expand All @@ -49,22 +56,28 @@ endif()
# add cross-platforms source files and header files
list(APPEND GAME_SOURCE
Classes/AppsFlyer/AppsFlyerX.cpp
Classes/AppsFlyer/AppsFlyerXAndroid.cpp
Classes/AppsFlyer/AppsFlyerProxyX.cpp
Classes/AppDelegate.cpp
Classes/HelloWorldScene.cpp
Classes/AppsFlyer/AppsFlyerXDeepLinkResult.cpp
)
list(APPEND GAME_HEADER
Classes/AppsFlyer/AppsFlyerX.h
Classes/AppsFlyer/AppsFlyerXAndroid.h
Classes/AppsFlyer/AppsFlyerProxyX.h
Classes/AppDelegate.h
Classes/HelloWorldScene.h
Classes/AppsFlyer/AppsFlyerXDeepLinkResult.h
)

if(ANDROID)
list(APPEND GAME_SOURCE
Classes/AppsFlyer/AppsFlyerXAndroid.cpp
Classes/AppsFlyer/AppsFlyerProxyX.cpp
)

list(APPEND GAME_HEADER
Classes/AppsFlyer/AppsFlyerXAndroid.h
Classes/AppsFlyer/AppsFlyerProxyX.h
)

# change APP_NAME to the share library name for Android, it's value depend on AndroidManifest.xml
set(APP_NAME MyGame)
list(APPEND GAME_SOURCE
Expand Down Expand Up @@ -145,7 +158,7 @@ if(APPLE)
)
elseif(IOS)
cocos_pak_xcode(${APP_NAME} INFO_PLIST "iOSBundleInfo.plist.in")
set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
# set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "")
set_xcode_property(${APP_NAME} CODE_SIGN_IDENTITY "iPhone Developer")
endif()
Expand Down
51 changes: 51 additions & 0 deletions Classes/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/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/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/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 */
2 changes: 1 addition & 1 deletion Classes/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/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
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::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
4 changes: 4 additions & 0 deletions Classes/AppsFlyer/AppsFlyerX.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "AppsFlyerXMacro.h"
#include "AppsFlyerXDeepLinkResult.h"
#include "AppsFlyerXConsent.cpp"
#include "AFSDKXPurchaseDetails.h"


class AppsFlyerX {
Expand Down Expand Up @@ -88,6 +89,9 @@ class AppsFlyerX {
const std::string& price,
const std::string& currency,
cocos2d::ValueMap additionalParameters);


static void validateAndLogInAppPurchase(AFSDKXPurchaseDetails &details, cocos2d::ValueMap params, std::function<void(AFSDKXValidateAndLogResult)> completionHandler);

static void logLocation(double longitude, double latitude);

Expand Down
6 changes: 6 additions & 0 deletions Classes/AppsFlyer/AppsFlyerXApple.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
//#include "AppsFlyerXAppleDelegate.h"
//#include "EmailCryptTypeX.h"
#include "AppsFlyerXDeepLinkResult.h"
#include "AFSDKXPurchaseDetails.h"
#include "AFSDKXValidateAndLogResult.h"

class AppsFlyerXApple {
private:
Expand Down Expand Up @@ -91,6 +93,10 @@ class AppsFlyerXApple {
std::function<void(cocos2d::ValueMap)> successBlock,
std::function<void(cocos2d::ValueMap)> failureBlock);

static void validateAndLogInAppPurchase(AFSDKXPurchaseDetails &details,
cocos2d::ValueMap params,
std::function<void(AFSDKXValidateAndLogResult)> completionHandler);

static void logLocation(double longitude, double latitude);

static std::string getAppsFlyerUID();
Expand Down
26 changes: 25 additions & 1 deletion Classes/AppsFlyer/AppsFlyerXApple.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
#include "AppsFlyerXAppleHelper.h"
#include "AppsFlyerXAppleDelegate.h"
#include "AppsFlyerXAppleDeepLinkDelegate.h"
#include "AFSDKXPurchaseDetails.h"
#include "AFSDKXValidateAndLogResult.h"
#import "libAppsFlyer/AppsFlyerLib.h"
#import "libAppsFlyer/AFSDKPurchaseDetails.h"
#import <UIKit/UIKit.h>


Expand Down Expand Up @@ -74,7 +77,7 @@
static AppsFlyerXApple *xApple = nil;
static AppsFlyerXAppleDelegate *delegate = nil;
[[AppsFlyerLib shared] setPluginInfoWith: AFSDKPluginCocos2dx
pluginVersion:@"6.13.0"
pluginVersion:@"6.15.3"
additionalParams:nil];
dispatch_once(&onceToken, ^{

Expand Down Expand Up @@ -249,6 +252,27 @@
}];
}


void AppsFlyerXApple::validateAndLogInAppPurchase(AFSDKXPurchaseDetails &details,
cocos2d::ValueMap params,
std::function<void(AFSDKXValidateAndLogResult)> completionHandler) {

NSString *productId = [NSString stringWithUTF8String:details.getProductId().c_str()];
NSString *price = [NSString stringWithUTF8String:details.getPrice().c_str()];
NSString *transactionId = [NSString stringWithUTF8String:details.getTransactionId().c_str()];
NSString *currency = [NSString stringWithUTF8String:details.getCurrency().c_str()];
NSDictionary *lParams = AppsFlyerXAppleHelper::valueMap2nsDictionary(params);

AFSDKPurchaseDetails *afPurchaseDetails = [[AFSDKPurchaseDetails alloc] initWithProductId:productId
price:price
currency:currency
transactionId:transactionId];

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

void AppsFlyerXApple::logLocation(double longitude, double latitude) {
[[AppsFlyerLib shared] logLocation:longitude latitude:latitude];
}
Expand Down
Loading

0 comments on commit 69868b5

Please sign in to comment.