애드브릭스 iOS 연동하기 [Cocos2d-x]
팔로우
SDK 설치
기존 프로젝트에서 시작
기존 cocos2d-x 프로젝트에서 연동을 진행하시는 경우 다음과 같이 2가지 셋팅이 필요합니다.
1. SDK 파일 복사
아래 스크린샷과 같이 SDK 및 플러그인 관련 파일들을 Xcode 프로젝트의 [Frameworks]에 Drag&Drop 하여 복사합니다.
[ libPluginAdBrix.a, libPluginProtocol.a, AdBrixRM.framework ]
2. cocos2d-x 플러그인 관련 소스 복사
ios의 경우 cocos2d-x 관련 플러그인&프로토콜 소스를 함께 사용하고 있습니다. 아래와 같은 경로에 [ plugin - protocols ] 디렉토리 전체를 기존 cocos2d-x 프로젝트의 동일한 디렉토리 위치에 복사합니다.
[ SDK 프로젝트의 plugin - protocols ]
[ 기존 프로젝트의 cocos2d-x 디렉토리 ]
3. 프레임워크 관련 path 설정
1, 2번 항목에서 복사한 SDK 및 플러그인 파일들의 디렉토리 경로들을 설정합니다.
*. 본 Path 설정시 상대경로가 정상적으로 설정되지 않으면 프로젝트 빌드가 불가능합니다.
[ Target - Build Settings - Framwork Search Paths, Header Search Paths, Library Search Paths ]
샘플 프로젝트에서 시작
AdBrix Cocos-2d-x 샘플프로젝트에는 SDK를 탑재한 샘플코드를 함꼐 제공하고 있습니다.
아래 스크린샷과 같이 프로젝트 구조를 확인하여 주십시오.
AdBrix Cosos-2d-x 프로젝트를 진행하기 위해서는 아래 선택된 파일들이 필요합니다.
[ HelloWorldScene.cpp,HelloWorldScene.h, libPluginAdBrix.a, libPluginProtocol.a, AdBrixRM.framework, AppContoller.mm 파일 체크 ]
*. HelloWorldScene.cpp, HelloWorldScene.h 파일은 프로젝트 상황에 맞게 바꾸시면 됩니다.
SDK 초기화
AdBrix SDK를 정상적으로 이용하기 위해서는 아래의 필수 초기화 작업을 진행해야 합니다.
- 애플광고식별자(IDFA) 설정
- 로그 레벨 설정
- 이벤트 업로드 주기 설정
- 앱키 설정
- 딥링크 설정
* 초기화 작업은 AppDelegate.swift 에서 진행해야하며, 이외의 곳에서 진행했을 때에는 예상하지 못한 문제가 발생할 수 있습니다.
애플광고식별자(IDFA) 설정
AdBrix Attribution 등의 광고 관련 기능을 이용하기 위해서는 반드시 애플광고식별자를 등록해야 합니다.
AppContoller.mm 파일에서 (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 함수 부분에 다음과 같이 IDFA를 설정합니다.
#import <AdSupport/AdSupport.h> #import "AdBrixRM/AdBrixRM-Swift.h" @implementation AppController static AppDelegate s_sharedApplication; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { AdBrixRM *adBrix = [AdBrixRM sharedInstance]; //또는 AdBrixRM *adBrix = AdBrixRM.sharedInstance; if (NSClassFromString(@"ASIdentifierManager")) { NSUUID *ifa =[[ASIdentifierManager sharedManager]advertisingIdentifier]; [adBrix setAppleAdvertisingIdentifier:[ifa UUIDString]]; } }
로그 레벨 설정
AdBrix SDK의 동작과 관련한 로그의 출력 수준을 설정합니다.
로그레벨은 1단계인 미출력을 포함하여 총 6단계로 구성되며, 2~6단계에서는 상위 레벨이 하위 레벨의 로그를 모두 포함하도록 구성되어 있습니다.
- AdBrixRM.AdBrixLogLevel.NONE : 로그를 출력하지 않습니다.
- AdBrixRM.AdBrixLogLevel.TRACE : 일반적인 내용이 담긴 개발 수준의 로그를 출력합니다.
- AdBrixRM.AdBrixLogLevel.DEBUG : TRACE를 포함한 디버깅용으로 작성한 개발 수준의 로그를 출력합니다.
- AdBrixRM.AdBrixLogLevel.INFO : TRACE, DEBUG를 포함한 데이터 저장, 로드, 전송 등 중요 수준의 로그를 출력합니다.
- AdBrixRM.AdBrixLogLevel.WARNING : TRACE, DEBUG, INFO를 Exception등의 치명적 오류가 아니나, 정상적 데이터 핸들링을 할 수 없는 위험이 있는 상태에 대한 로그를 출력합니다.
- AdBrixRM.AdBrixLogLevel.ERROR : TRACE, DEBUG, INFO, WARNING을 모두 포함한 Exception등의 치명적 오류로그까지 출력합니다.
#import <AdSupport/AdSupport.h> #import "AdBrixRM/AdBrixRM-Swift.h" @implementation AppController static AppDelegate s_sharedApplication; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { AdBrixRM *adBrix = [AdBrixRM sharedInstance]; //또는 AdBrixRM *adBrix = AdBrixRM.sharedInstance; [adBrix setLogLevel:AdBrixLogLevelERROR]; }
이벤트 업로드 주기 설정
AdBrix SDK 에 전달된 이벤트를 AdBrix 서버로 전송하는 기준을 설정할 수 있습니다.
이벤트 업로드 주기를 누적 이벤트 개수와 시간으로 설정할 수 있습니다.
* 두 가지 기준 중 먼저 충족되는 기준에 따라서 이벤트가 업로드 됩니다.
누적 이벤트 개수 기준
설정된 개수만큼 이벤트가 누적되었을 때에 AdBrix 서버로 이벤트를 업로드하도록 설정합니다.
AdBrix SDK에 사전 정의된 아래의 값을 이용하여 설정합니다.
- AdBrixRM.AdBrixEventUploadCountInterval.MIN : 10건
- AdBrixRM.AdBrixEventUploadCountInterval.NORMAL : 30건
- AdBrixRM.AdBrixEventUploadCountInterval.MAX : 60건
#import <AdSupport/AdSupport.h> #import "AdBrixRM/AdBrixRM-Swift.h" @implementation AppController static AppDelegate s_sharedApplication; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { AdBrixRM *adBrix = [AdBrixRM sharedInstance]; //또는 AdBrixRM *adBrix = AdBrixRM.sharedInstance; [adBrix setEventUploadCountInterval:AdBrixEventUploadCountIntervalMIN]; }
시간 기준
설정된 시간이 지나면 AdBrix 서버로 이벤트를 업로드하도록 설정합니다.
AdBrix SDK에 사전 정의된 아래의 값을 이용하여 설정합니다.
- AdBrixRM.AdBrixEventUploadTimeInteval.MIN : 30초
- AdBrixRM.AdBrixEventUploadTimeInteval.NORMAL :60초
- AdBrixRM.AdBrixEventUploadTimeInteval.MAX :120초
#import <AdSupport/AdSupport.h> #import "AdBrixRM/AdBrixRM-Swift.h" @implementation AppController static AppDelegate s_sharedApplication; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { AdBrixRM *adBrix = [AdBrixRM sharedInstance]; //또는 AdBrixRM *adBrix = AdBrixRM.sharedInstance; [adBrix setEventUploadTimeInterval:AdBrixEventUploadTimeIntervalMIN]; }
앱키 & 시크릿키 설정
AdBrix 홈페이지에서 발급받은 앱키와 시크릿키를 등록합니다.
#import <AdSupport/AdSupport.h> #import "AdBrixRM/AdBrixRM-Swift.h" @implementation AppController static AppDelegate s_sharedApplication; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { AdBrixRM *adBrix = [AdBrixRM sharedInstance]; //또는 AdBrixRM *adBrix = AdBrixRM.sharedInstance; [adBrix initAdBrixWithAppKey:@"fnbFMvaGgkGVcajnoIeUTw" secretKey:@"mj2kvH7FL0Gdv15yaX2Cuw"]; }
* AdBrix Classic 과 AdBrix Remaster 의 앱키는 서로 다릅니다.
* AdBrix Remaster 앱키&시크릿키는 android, ios 플랫폼 간 구분이 없이 공용으로 사용합니다.
딥링크 설정
딥링크가 설정된 url 을 통해서 오픈된 이벤트를 분석합니다.
분석을 하기 위해서는 앱에 custom url scheme 이 설정되어 있어야 합니다.
Custom Url Scheme 설정
Xcode 프로젝트를 오픈합니다.
[General > Target > Info > URL Types] 로 이동하여 다음과 같이 URL Scheme 을 설정합니다.
딥링크 오픈 이벤트
AppDelegate.mm에 아래의 2가지 함수를 추가 합니다.
//functions of deeplink #if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_9_0 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { NSLog(@"DEEPLINK :: DeepLink Called !! - %@", url); [[AdBrixRM sharedInstance] deepLinkOpenWithUrl:url]; return YES; } #else - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { NSLog(@"DEEPLINK :: DeepLink Called !!! - %@", url); [[AdBrixRM sharedInstance] deepLinkOpenWithUrl:url]; return YES; } #endif
유니버셜 링크 설정
*. 유니버셜 링크 기능이 정상 동작하기 위해서는 다음 스크린샷과 같이 애플 개발자 Identifiers에 Associated Domains 이 동일하게 ON으로 처리되어 있는 상태에서 다음 과정들을 진행하셔야 합니다.
Xcode 프로젝트를 오픈합니다.
[ Target > Capabilities > Associated Domains ] 로 이동하여 다음과 같이 URL 을 설정합니다.
*. 위 스크린샷에서처럼 입력하는 Domains 부분의 appKey 라는 문자열은 실제 서버에서 발급받은 고객님의 App Key 원문을 복사하여 입력하여 주십시오.
ex) applinks:dnbfagaggkgdcosavieuqd.adtouch.adbrix.io
다음과 같이 유니버셜 링크를 수신하는 application 함수를 작성합니다.
#import <AdSupport/AdSupport.h> #import "AdBrixRM/AdBrixRM-Swift.h" @interface AppController () {} @end @implementation AppController static AppDelegate s_sharedApplication; -(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler{ if ([userActivity.activityType isEqualToString: NSUserActivityTypeBrowsingWeb]) { NSURL *url = userActivity.webpageURL; NSLog(@"DEEPLINK :: UniversialLink Called !! - %@", url); [[AdBrixRM sharedInstance] deepLinkOpenWithUrl:url]; } return YES; }
*. url 변수에 유니버셜 링크가 정상 동작하였을 경우 URL 값이 들어있습니다.
디퍼드 딥링크 설정
다음과 깉이 AdBrixRMDeeplinkDelegate 델리게이트를 등록하고, 콜백 함수 didReceiveDeeplinkWithDeeplink를 상속 구현합니다.
#import <AdSupport/AdSupport.h> #import "AdBrixRM/AdBrixRM-Swift.h" @interface AppController () {} @end @implementation AppController static AppDelegate s_sharedApplication; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { AdBrixRM *adBrix = [AdBrixRM sharedInstance]; [adBrix setDeeplinkDelegateWithDelegate:self]; } - (void)didReceiveDeeplinkWithDeeplink:(NSString * _Nonnull)deeplink { NSLog(@"didReceiveDeeplinkWithDeeplink: %@", deeplink); }
*. deeplink 변수에 디퍼드 딥링크가 정상 동작하였을 경우 URL 값이 들어있습니다.
SDK 초기화 전체 예시
위 5가지 항목을 모두 연동했을 때의 연동 코드는 다음과 같습니다.
#import "AppController.h" #import "platform/ios/CCEAGLView-ios.h" #import "cocos2d.h" #import "AppDelegate.h" #import "RootViewController.h" #import <AdSupport/AdSupport.h> #import "AdBrixRM/AdBrixRM-Swift.h" //regist deferred deeplink delegate @interface AppController () {} @end @implementation AppController static AppDelegate s_sharedApplication; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { AdBrixRM *adBrix = [AdBrixRM sharedInstance]; if (NSClassFromString(@"ASIdentifierManager")) { NSUUID *ifa =[[ASIdentifierManager sharedManager]advertisingIdentifier]; //idfa [adBrix setAppleAdvertisingIdentifier:[ifa UUIDString]]; } //log level [adBrix setLogLevel:AdBrixLogLevelERROR]; //event upload count interval [adBrix setEventUploadCountInterval:AdBrixEventUploadCountIntervalMIN]; //event upload time interval [adBrix setEventUploadTimeInterval:AdBrixEventUploadTimeIntervalMIN]; //add deferred deeplink delegate [adBrix setDeeplinkDelegateWithDelegate:self]; //AdBrix Initialize [adBrix initAdBrixWithAppKey:@"inputYourAppKey" secretKey:@"inputYourSecretKey"]; } //functions of deeplink #if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_9_0 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { NSLog(@"DEEPLINK :: DeepLink Called !! - %@", url); [[AdBrixRM sharedInstance] deepLinkOpenWithUrl:url]; return YES; } #else - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { NSLog(@"DEEPLINK :: DeepLink Called !!! - %@", url); [[AdBrixRM sharedInstance] deepLinkOpenWithUrl:url]; return YES; } #endif -(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler{ if ([userActivity.activityType isEqualToString: NSUserActivityTypeBrowsingWeb]) { NSURL *url = userActivity.webpageURL; NSLog(@"DEEPLINK :: UniversialLink Called !! - %@", url); [[AdBrixRM sharedInstance] deepLinkOpenWithUrl:url]; } return YES; } //deferred deeplink url - (void)didReceiveDeeplinkWithDeeplink:(NSString * _Nonnull)deeplink { NSLog(@"didReceiveDeeplinkWithDeeplink: %@", deeplink); }
Xcode 프로젝트 설정
최종 빌드를 위해 확인 및 수정하여야할 Xcode 프로젝트의 옵션 사항은 아래와 같습니다.
- swift 라이브러리 설정
- other linker flags 설정
- framework import 상태 확인
플러그인 설정
다음 섹션의 이벤트 분석 기능을 사용하기 위해서는 아래 코드예제와 같이 분석을 사용하고자 하는 cpp, h에 플러그인 변수 설정이 필요합니다.
다음 예제는 샘플 프로젝트의 HelloWorldScene.cpp 과 HelloWorldScene.h 파일 기준으로 작성하였습니다.
HelloWorldScene.h
class HelloWorld : public cocos2d::Layer { public: static cocos2d::Scene* createScene(); virtual bool init(); void loadAdBrixRmPlugin(); void unloadAdBrixRmPlugin(); // implement the "static create()" method manually CREATE_FUNC(HelloWorld); cocos2d::plugin::ProtocolAnalytics* _pluginAdBrixRm; private: };
HelloWorldScene.cpp
void HelloWorld::loadAdBrixRmPlugin() { _pluginAdBrixRm = dynamic_cast<ProtocolAnalytics*>(PluginManager::getInstance()->loadPlugin("PluginAdBrix")); printf("AdBrixRm plugin = %s", _pluginAdBrixRm->getPluginName()); } void HelloWorld::unloadAdBrixRmPlugin() { if (NULL != _pluginAdBrixRm) { std::string pluginName = _pluginAdBrixRm->getPluginName(); PluginManager::getInstance()->unloadPlugin(pluginName.c_str()); _pluginAdBrixRm = NULL; } }
GDPR 설정
GDPR 요청 이벤트를 이용하여 사용자 요청에 대해 데이터 주체와 연관된 모든 개인 데이터를 삭제할 수 있습니다.
본 이벤트 호출시, SDK 동작은 정지되며 모든 이벤트 저장, 전송 등이 불가합니다.
본 기능은 사용자가 앱을 삭제 후, 재설치하기 전에는 되돌릴 수 없습니다.
void HelloWorld::menuGdprForgetMeCallback() { //플러그인 로드 cocos2d::plugin::ProtocolAnalytics* _pluginAdBrixRm; _pluginAdBrixRm = dynamic_cast<ProtocolAnalytics*>(PluginManager::getInstance()->loadPlugin("PluginAdBrix")); _pluginAdBrixRm->callFuncWithParam("gdprForgetMe", NULL); }
이벤트 분석
앱에서 발생하는 인-앱 이벤트(in-app event)를 분석하여 리포트를 구성하고 포스트백을 전송할 수 있습니다.
이벤트 분석을 위해서는 이벤트가 발생하는 시점에 이벤트 분석 코드를 삽입하고 이벤트 식별값을 전송하여야 합니다.
AdBrix 는 크게 3가지 분류의 분석을 제공합니다.
- 유저 분석
- 로그인/로그아웃 이벤트
- 유저 정보
- 커스텀 분석
- 공통(일반) 분석
- 회원가입
- 앱 업데이트
- 사용자 초대
- 크레딧 사용
- 결제하기
- 게임 분석
- 튜토리얼 완료
- 케릭터 생성
- 스테이지 완료
- 레벨 달성
유저 분석
로그인/로그아웃 이벤트
사용자의 로그인/로그아웃 이벤트를 분석합니다.
로그인이 성공하였을 때, 유저를 구분하는 식별값(user id)을 다음과 같이 전달합니다.
로그아웃이 성공하였을 때, @"" 와 같이 빈 문자열을 전달하여 유저 로그인 데이터를 초기화합니다.
void HelloWorld::menuLoginCallback(cocos2d::Ref* pSender) { PluginParam pEventName1("adbrixremasteruser"); _pluginAdBrixRm->callFuncWithParam("login", &pEventName1, NULL); bool isLoginSucc = false; if(isLoginSucc) { // 로그인이 성공했을 떄, "user_1234"와 같은 유저아이디를 전달 PluginParam pEventName1("adbrixremasteruser"); _pluginAdBrixRm->callFuncWithParam("login", &pEventName1, NULL); } else { // 로그아웃이 성공했을 때, ""의 빈 문자열을 전달 PluginParam pEventName1(""); _pluginAdBrixRm->callFuncWithParam("login", &pEventName1, NULL); } }
* userId 로 전달되는 유저 아이디에 개인정보가 포함되지 않도록 주의해주세요. 만약 이메일, 전화번호 등의 개인정보가 포함되는 경우에는 적절한 암호화(BASE64, MD5, SHA1 등) 처리를 하시는 것을 권장합니다.
유저 정보
유저의 나이, 성별, 기타 정보에 대해 분석할 수 있습니다.
void HelloWorld::menuPropsCallback(cocos2d::Ref* pSender) { //유저 나이 PluginParam pAge(20); _pluginAdBrixRm->callFuncWithParam("setAge", &pAge, NULL); //유저 성별 PluginParam pGender(1); _pluginAdBrixRm->callFuncWithParam("setGender", &pGender, NULL); //기타 유저 정보 std::map<std::string,std::string> pEventParam; pEventParam["nickname"] = "adbrixrm"; pEventParam["birthday"] = "2018"; PluginParam pEventParams(pEventParam); _pluginAdBrixRm->callFuncWithParam("setUserProperties", &pEventParams, NULL); }
* 유저 정보 사용에 대한 동의에 대한 책임은 AdBrix 가 아닌 앱 개발 및 운영 주체입니다.
* 기타유저정보로 전달되는 NSDictionary 의 제약사항
- 100개 이상의 정보는 처리되지 않습니다.
- 키 값의 데이터 타입은 String이며, 256자를 넘을 수 없습니다.
- 밸류 값의 데이터 길이는 byte기준으로 1024byte를 넘을 수 없습니다.
위치 정보
사용자의 위치 정보를 얻을 수 있는 경우, 이를 분석할 수 있습니다.
void sampleFunction() { // 위도 경도 정보 업데이트 AdBrixRm.setLocationWithLatitude(39.00, 121.00); }
* 위치 정보 사용에 대한 동의에 대한 책임은 AdBrix 가 아닌 앱 개발 및 운영 주체입니다.
커스텀 분석
앱 내 사용자의 일반적인 모든 이벤트를 분석합니다. (구매 이벤트 제외)
앱 내에서 이벤트(string)를 통해 액션을 자유롭게 분석할 수 있습니다.
void HelloWorld::menuEventsCallback(Ref* pSender) //커스텀 이벤트 //just custom event with name PluginParam pEventName1("customEvents01"); _pluginAdBrixRm->callFuncWithParam("events", &pEventName1, NULL); //custom event with name and parameter map PluginParam pEventName2("customEvents02"); std::map<std::string,std::string> pEventParam; pEventParam["test_key0"] = "test_value0"; pEventParam["test_key1"] = "test_value1"; pEventParam["test_key2"] = "test_value2"; PluginParam pEventParams(pEventParam); _pluginAdBrixRm->callFuncWithParam("eventsWithParam", &pEventName2, &pEventParams, NULL); }
공통(일반)이벤트 분석
앱에서 발생하는 이벤트 중, 공통적으로 발생하는 이벤트를 분석합니다.
AdBrix 에서 제공하는 공통 이벤트 종류는 다음과 같습니다.
- 회원가입
- 앱 업데이트
- 사용자 초대
- 크레딧 사용
- 결제하기
* AdBrix 에서 광고채널 별 매출을 보고자 할 때에는 '결제하기' 연동을 반드시 진행해야 합니다.
회원가입
앱에서 발생한 회원가입 이벤트를 분석합니다.
void HelloWorld::menuCommonSignUpCallback(cocos2d::Ref* pSender) { PluginParam pSignChannel(AdBrixSignUpNaverChannel); std::map<std::string,std::string> pAttrParam; pAttrParam["test_key"] = "test_value"; PluginParam pAttrParams(pAttrParam); _pluginAdBrixRm->callFuncWithParam("commonSignUp", &pSignChannel, &pAttrParams, NULL); }
앱 업데이트
앱에서 발생한 앱 업데이트 이벤트를 분석합니다.
void HelloWorld::menuCommonAppUpdateCallback(cocos2d::Ref* pSender) { PluginParam pPrevVer("1.0"); PluginParam pCurrVer("1.1"); std::map<std::string,std::string> pAttrParam; pAttrParam["market"] = "app_store"; PluginParam pAttrParams(pAttrParam); _pluginAdBrixRm->callFuncWithParam("commonAppUpdate", &pPrevVer, &pCurrVer, &pAttrParams, NULL); }
사용자 초대
앱에서 발생한 앱 초대 이벤트를 분석합니다.
void HelloWorld::menuCommonInviteCallback(cocos2d::Ref* pSender) { PluginParam pinviteChannel(AdBrixInviteKakaoChannel); std::map<std::string,std::string> pAttrParam; pAttrParam["test_key"] = "test_value"; PluginParam pAttrParams(pAttrParam); _pluginAdBrixRm->callFuncWithParam("commonInvite", &pinviteChannel, &pAttrParams, NULL); }
크레딧 사용
앱내 현금성 화폐 사용에 대한 이벤트를 분석합니다.
void HelloWorld::menuCommonUseCreditCallback(cocos2d::Ref* pSender) { std::map<std::string,std::string> pAttrParam; pAttrParam["type"] = "gold"; PluginParam pAttrParams(pAttrParam); _pluginAdBrixRm->callFuncWithParam("commonUseCredit", &pAttrParams, NULL); }
결제하기
앱에서 발생한 결제(구매) 이벤트를 분석합니다.
다음과 같은 상품 맟 주문에 대한 정보를 array 형태로 구성하여 전달합니다.
- order id : (필수) 주문번호
- product id : (필수) 상품번호
- product name : (필수) 상품이름
- price : (필수) 상품단가
- quantity : (필수) 구매수량
- discount : (옵션) 할인금액
- currency string : (옵션) 카테고리 정보
- category : (옵션) 구매 화폐 단위
- product attr map : (옵션) 상품 상세 옵션
- delivery charge : (옵션) 배송비
- payment method : (옵션) 결제 방법
void HelloWorld::menuCommonPurchaseBulkCallback(cocos2d::Ref* pSender) { std::map<std::string,std::string> pMap; //상품별 Attr 값 pMap["productattr_key01"]="productattr_value01"; pMap["productattr_key02"]="productattr_value02"; AdBrixRmCommerceProductAttrModel *attr = AdBrixRmCommerceProductAttrModel::create(pMap); AdBrixRmCommerceProductCategoryModel *cat = AdBrixRmCommerceProductCategoryModel::create("cat1", "cat2"); AdBrixRmCommerceProductModel *pProductModel = NULL; PluginParam pCurrency(AdBrixCurrencyKRW); std::string currencyStr = _pluginAdBrixRm->callStringFuncWithParam("currencyName", &pCurrency, NULL); //각 상품에 정보를 담을 Map std::map<std::string,std::string> pProductMap; //상품 정보입력 pProductMap["key01"]=pProductModel->AdBrixRmCommerceProductModel::create("cocos2d_x_PRODUCT_ID01", "cocos2d_x_PRODUCT_NAME01", 500.0, 100.0, 1, currencyStr.c_str(), cat, attr).c_str(); pProductModel = NULL; pProductMap["key02"]=pProductModel->AdBrixRmCommerceProductModel::create("cocos2d_x_PRODUCT_ID02", "cocos2d_x_PRODUCT_NAME02", 600.0, 200.0, 1, currencyStr.c_str(), cat, attr).c_str(); pProductModel = NULL; pProductMap["key03"]=pProductModel->AdBrixRmCommerceProductModel::create("cocos2d_x_PRODUCT_ID03", "cocos2d_x_PRODUCT_NAME03", 700.0, 300.0, 1, currencyStr.c_str(), cat, attr).c_str(); //상품을 담을 배열 PluginParam pProductList(pProductMap); PluginParam pOrderId("290192012"); PluginParam pDiscount(4000); PluginParam pDeliveryCharge(4000); PluginParam pPaymentMethod(AdBrixPaymentCreditCard); //주문단위 Attr 값 std::map<std::string,std::string> pOrderAttrParam; pOrderAttrParam["orderattr_key01"] = "orderattr_value01"; PluginParam pOrderAttrParams(pOrderAttrParam); //결제 이벤트 _pluginAdBrixRm->callFuncWithParam("commonPurchaseBulk", &pOrderId, &pProductList, &pDiscount, &pDeliveryCharge, &pPaymentMethod, &pOrderAttrParams, NULL); }
게임 이벤트 분석
앱에서 발생하는 게임과 관련된 이벤트(튜토리얼, 스테이지 등)를 분석합니다.
AdBrix 에서 제공하는 게임 이벤트 종류는 다음과 같습니다.
- 튜토리얼 완료
- 캐릭터 생성
- 스테이지 완료
- 레벨 달성
튜토리얼 완료
앱에서 발생한 튜토리얼 완료 이벤트를 분석합니다.
다음과 같은 튜토리얼 완료 정보를 구성하여 전달합니다.
- (필수) 건너뛰기(skip)를 통한 완료인지 여부
void HelloWorld::menuGameTutorialCompletedCallback(cocos2d::Ref* pSender) { PluginParam pIsSkip(false); std::map<std::string,std::string> pAttrParam; pAttrParam["gold"] = "10"; PluginParam pAttrParams(pAttrParam); _pluginAdBrixRm->callFuncWithParam("gameTutorialCompleted", &pIsSkip, &pAttrParams, NULL); }
캐릭터 생성
앱에서 발생한 캐릭터 생성 이벤트를 분석합니다.
void HelloWorld::menuGameCharacterCreatedCallback(cocos2d::Ref* pSender) { std::map<std::string,std::string> pAttrParam; pAttrParam["gold"] = "10"; PluginParam pAttrParams(pAttrParam); _pluginAdBrixRm->callFuncWithParam("gameCharacterCreated", &pAttrParams, NULL); }
스테이지 완료
앱에서 발생한 스테이지 완료 이벤트를 분석합니다.
다음과 같은 스테이지 완료 정보를 구성하여 전달합니다.
- (필수) 완료한 스테이지 이름
void HelloWorld::menuGameStageClearedCallback(cocos2d::Ref* pSender) { PluginParam pStageName("1-1"); std::map<std::string,std::string> pAttrParam; pAttrParam["gold"] = "10"; PluginParam pAttrParams(pAttrParam); _pluginAdBrixRm->callFuncWithParam("gameStageCleared", &pStageName, &pAttrParams, NULL); }
레벨 달성
앱에서 발생한 레벨 달성 이벤트를 분석합니다.
다음과 같은 레벨 달성 정보를 구성하여 전달합니다.
- (필수) 달성한 레벨 (1~10000)
void HelloWorld::menuGameLevelAchievedCallback(cocos2d::Ref* pSender) { PluginParam pLevel(10); std::map<std::string,std::string> pAttrParam; pAttrParam["gold"] = "10"; pAttrParam["prev_all_cleared"] = "n"; PluginParam pAttrParams(pAttrParam); _pluginAdBrixRm->callFuncWithParam("gameLevelAchieved", &pLevel, &pAttrParams, NULL); }
댓글
댓글 0개
댓글을 남기려면 로그인하세요.