mirror of https://github.com/axmolengine/axmol.git
Refactor the framework of plugin on iOS.
This commit is contained in:
parent
587dfb8e9f
commit
3ce52e56aa
|
@ -23,6 +23,7 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
#include "AnalyticsFlurry.h"
|
||||
#include "Flurry.h"
|
||||
#include "PluginUtilsIOS.h"
|
||||
|
||||
namespace cocos2d { namespace plugin {
|
||||
|
||||
|
@ -52,19 +53,14 @@ AnalyticsFlurry::~AnalyticsFlurry()
|
|||
|
||||
bool AnalyticsFlurry::init()
|
||||
{
|
||||
return true;
|
||||
return PluginUtilsIOS::initOCPlugin(this, "FlurryWrapper");
|
||||
}
|
||||
|
||||
/** override methods of base class */
|
||||
/** Start a new session. */
|
||||
void AnalyticsFlurry::startSession(const char* appKey)
|
||||
{
|
||||
if (NULL == appKey || strlen(appKey) == 0) {
|
||||
FlurryLogD("appkey is invalid!");
|
||||
return;
|
||||
}
|
||||
NSString* pKey = [NSString stringWithUTF8String:appKey];
|
||||
[Flurry startSession:pKey];
|
||||
ProtocolAnalytics::startSession(appKey);
|
||||
}
|
||||
|
||||
/** Stop a session.
|
||||
|
@ -72,83 +68,43 @@ void AnalyticsFlurry::startSession(const char* appKey)
|
|||
*/
|
||||
void AnalyticsFlurry::stopSession()
|
||||
{
|
||||
ProtocolAnalytics::stopSession();
|
||||
}
|
||||
|
||||
/** Set whether needs to output logs to console.*/
|
||||
void AnalyticsFlurry::setDebugMode(bool debug)
|
||||
{
|
||||
s_bDebugable = debug;
|
||||
[Flurry setDebugLogEnabled:debug];
|
||||
ProtocolAnalytics::setDebugMode(debug);
|
||||
}
|
||||
|
||||
/** Set the timeout for expiring a session. */
|
||||
void AnalyticsFlurry::setSessionContinueMillis(long millis)
|
||||
{
|
||||
int seconds = (int)(millis / 1000);
|
||||
[Flurry setSessionContinueSeconds:seconds];
|
||||
ProtocolAnalytics::setSessionContinueMillis(millis);
|
||||
}
|
||||
|
||||
/** log an error */
|
||||
void AnalyticsFlurry::logError(const char* errorId, const char* message)
|
||||
{
|
||||
if (NULL == errorId || strlen(errorId) == 0) {
|
||||
FlurryLogD("errorId is invalid!");
|
||||
return;
|
||||
}
|
||||
NSString* pId = [NSString stringWithUTF8String:errorId];
|
||||
NSString* msg = nil;
|
||||
if (NULL == message) {
|
||||
msg = @"";
|
||||
} else {
|
||||
msg = [NSString stringWithUTF8String:message];
|
||||
}
|
||||
[Flurry logError:pId message:msg exception:nil];
|
||||
ProtocolAnalytics::logError(errorId, message);
|
||||
}
|
||||
|
||||
/** log an event. */
|
||||
void AnalyticsFlurry::logEvent(const char* eventId, LogEventParamMap* paramMap)
|
||||
{
|
||||
if (NULL == eventId || strlen(eventId) == 0) {
|
||||
FlurryLogD("eventId is invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
NSString* pId = [NSString stringWithUTF8String:eventId];
|
||||
if (NULL == paramMap) {
|
||||
[Flurry logEvent:pId];
|
||||
} else {
|
||||
NSMutableDictionary* dict = [NSMutableDictionary dictionary];
|
||||
LogEventParamMap::iterator it;
|
||||
for (it = paramMap->begin(); it != paramMap->end(); it++) {
|
||||
std::string key = it->first;
|
||||
std::string value = it->second;
|
||||
NSString* pKey = [NSString stringWithUTF8String:key.c_str()];
|
||||
NSString* pValue = [NSString stringWithUTF8String:value.c_str()];
|
||||
[dict setObject:pValue forKey:pKey];
|
||||
}
|
||||
[Flurry logEvent:pId withParameters:dict];
|
||||
}
|
||||
ProtocolAnalytics::logEvent(eventId, paramMap);
|
||||
}
|
||||
|
||||
void AnalyticsFlurry::logTimedEventBegin(const char* eventId)
|
||||
{
|
||||
if (NULL == eventId || strlen(eventId) == 0) {
|
||||
FlurryLogD("eventId is invalid!");
|
||||
return;
|
||||
}
|
||||
NSString* pId = [NSString stringWithUTF8String:eventId];
|
||||
[Flurry logEvent:pId timed:YES];
|
||||
ProtocolAnalytics::logTimedEventBegin(eventId);
|
||||
}
|
||||
|
||||
/** end a timed event */
|
||||
void AnalyticsFlurry::logTimedEventEnd(const char* eventId)
|
||||
{
|
||||
if (NULL == eventId || strlen(eventId) == 0) {
|
||||
FlurryLogD("eventId is invalid!");
|
||||
return;
|
||||
}
|
||||
NSString* pId = [NSString stringWithUTF8String:eventId];
|
||||
[Flurry endTimedEvent:pId withParameters:nil];
|
||||
ProtocolAnalytics::logTimedEventEnd(eventId);
|
||||
}
|
||||
|
||||
/** Whether to catch uncaught exceptions to server.
|
||||
|
@ -156,17 +112,18 @@ void AnalyticsFlurry::logTimedEventEnd(const char* eventId)
|
|||
*/
|
||||
void AnalyticsFlurry::setCaptureUncaughtException(bool enabled)
|
||||
{
|
||||
ProtocolAnalytics::setCaptureUncaughtException(enabled);
|
||||
}
|
||||
|
||||
const char* AnalyticsFlurry::getSDKVersion()
|
||||
{
|
||||
NSString* ver = [Flurry getFlurryAgentVersion];
|
||||
return [ver UTF8String];
|
||||
return ProtocolAnalytics::getSDKVersion();
|
||||
}
|
||||
|
||||
void AnalyticsFlurry::setAge(int age)
|
||||
{
|
||||
[Flurry setAge:age];
|
||||
NSNumber* numAge = [NSNumber numberWithInt:age];
|
||||
PluginUtilsIOS::callOCFunctionWithName_Object(this, "setAge:", numAge);
|
||||
}
|
||||
|
||||
void AnalyticsFlurry::setGender(Gender gender)
|
||||
|
@ -175,7 +132,7 @@ void AnalyticsFlurry::setGender(Gender gender)
|
|||
if (gender == FEMALE) {
|
||||
ret = @"f";
|
||||
}
|
||||
[Flurry setGender:ret];
|
||||
PluginUtilsIOS::callOCFunctionWithName_Object(this, "setGender:", ret);
|
||||
}
|
||||
|
||||
void AnalyticsFlurry::setUserId(const char* userId)
|
||||
|
@ -185,18 +142,18 @@ void AnalyticsFlurry::setUserId(const char* userId)
|
|||
return;
|
||||
}
|
||||
NSString* pUserID = [NSString stringWithUTF8String:userId];
|
||||
[Flurry setUserID:pUserID];
|
||||
PluginUtilsIOS::callOCFunctionWithName_Object(this, "setUserId:", pUserID);
|
||||
}
|
||||
|
||||
void AnalyticsFlurry::logPageView()
|
||||
{
|
||||
[Flurry logPageView];
|
||||
PluginUtilsIOS::callOCFunctionWithName(this, "logPageView");
|
||||
}
|
||||
|
||||
|
||||
void AnalyticsFlurry::setVersionName(const char* versionName)
|
||||
{
|
||||
NSString* pVer = [NSString stringWithUTF8String:versionName];
|
||||
[Flurry setAppVersion:pVer];
|
||||
PluginUtilsIOS::callOCFunctionWithName_Object(this, "setVersionName:", pVer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -204,7 +161,7 @@ void AnalyticsFlurry::setVersionName(const char* versionName)
|
|||
*/
|
||||
void AnalyticsFlurry::setUseHttps(bool useHttps)
|
||||
{
|
||||
|
||||
FlurryLogD("setUseHttps in flurry not available on iOS");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,7 +169,7 @@ void AnalyticsFlurry::setUseHttps(bool useHttps)
|
|||
*/
|
||||
void AnalyticsFlurry::setReportLocation(bool enabled)
|
||||
{
|
||||
|
||||
FlurryLogD("setReportLocation in flurry not available on iOS");
|
||||
}
|
||||
|
||||
void AnalyticsFlurry::logTimedEventBegin(const char* eventId, LogEventParamMap* paramMap)
|
||||
|
@ -221,21 +178,20 @@ void AnalyticsFlurry::logTimedEventBegin(const char* eventId, LogEventParamMap*
|
|||
FlurryLogD("eventId is invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
NSString* pId = [NSString stringWithUTF8String:eventId];
|
||||
if (NULL == paramMap) {
|
||||
[Flurry logEvent:pId timed:YES];
|
||||
this->logTimedEventBegin(eventId);
|
||||
} else {
|
||||
NSMutableDictionary* dict = [NSMutableDictionary dictionary];
|
||||
LogEventParamMap::iterator it;
|
||||
for (it = paramMap->begin(); it != paramMap->end(); it++) {
|
||||
std::string key = it->first;
|
||||
std::string value = it->second;
|
||||
NSString* pKey = [NSString stringWithUTF8String:key.c_str()];
|
||||
NSString* pValue = [NSString stringWithUTF8String:value.c_str()];
|
||||
[dict setObject:pValue forKey:pKey];
|
||||
NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(paramMap);
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
if (pData) {
|
||||
id pOCObj = pData->obj;
|
||||
SEL selector = NSSelectorFromString(@"logTimedEventBegin:withParam:");
|
||||
if ([pOCObj respondsToSelector:selector]) {
|
||||
[pOCObj performSelector:selector withObject:pId withObject:dict];
|
||||
}
|
||||
}
|
||||
[Flurry logEvent:pId withParameters:dict timed:YES];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,18 +204,17 @@ void AnalyticsFlurry::logTimedEventEnd(const char* eventId, LogEventParamMap* pa
|
|||
|
||||
NSString* pId = [NSString stringWithUTF8String:eventId];
|
||||
if (NULL == paramMap) {
|
||||
[Flurry endTimedEvent:pId withParameters:nil];
|
||||
this->logTimedEventEnd(eventId);
|
||||
} else {
|
||||
NSMutableDictionary* dict = [NSMutableDictionary dictionary];
|
||||
LogEventParamMap::iterator it;
|
||||
for (it = paramMap->begin(); it != paramMap->end(); it++) {
|
||||
std::string key = it->first;
|
||||
std::string value = it->second;
|
||||
NSString* pKey = [NSString stringWithUTF8String:key.c_str()];
|
||||
NSString* pValue = [NSString stringWithUTF8String:value.c_str()];
|
||||
[dict setObject:pValue forKey:pKey];
|
||||
NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(paramMap);
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
if (pData) {
|
||||
id pOCObj = pData->obj;
|
||||
SEL selector = NSSelectorFromString(@"logTimedEventEnd:withParam:");
|
||||
if ([pOCObj respondsToSelector:selector]) {
|
||||
[pOCObj performSelector:selector withObject:pId withObject:dict];
|
||||
}
|
||||
}
|
||||
[Flurry endTimedEvent:pId withParameters:dict];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2012-2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#import "InterfaceAnalytics.h"
|
||||
|
||||
@interface FlurryWrapper : NSObject <InterfaceAnalytics>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
interfaces of protocol : InterfaceAnalytics
|
||||
*/
|
||||
- (void) startSession: (NSString*) appKey;
|
||||
- (void) stopSession;
|
||||
- (void) setSessionContinueMillis: (NSNumber*) millis;
|
||||
- (void) setCaptureUncaughtException: (NSNumber*) isEnabled;
|
||||
- (void) setDebugMode: (NSNumber*) isDebugMode;
|
||||
- (void) logError: (NSString*) errorId withMsg:(NSString*) message;
|
||||
- (void) logEvent: (NSString*) eventId;
|
||||
- (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap;
|
||||
- (void) logTimedEventBegin: (NSString*) eventId;
|
||||
- (void) logTimedEventEnd: (NSString*) eventId;
|
||||
- (NSString*) getSDKVersion;
|
||||
|
||||
/**
|
||||
interfaces of flurry SDK
|
||||
*/
|
||||
- (void) setAge: (NSNumber*) age;
|
||||
- (void) setGender: (NSString*) gender;
|
||||
- (void) setUserId: (NSString*) userId;
|
||||
- (void) logPageView;
|
||||
- (void) setVersionName: (NSString*) versionName;
|
||||
- (void) logTimedEventBegin: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap;
|
||||
- (void) logTimedEventEnd: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap;
|
||||
|
||||
@end
|
|
@ -0,0 +1,129 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2012-2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#import "FlurryWrapper.h"
|
||||
#import "Flurry.h"
|
||||
|
||||
@implementation FlurryWrapper
|
||||
|
||||
- (void) startSession: (NSString*) appKey
|
||||
{
|
||||
[Flurry startSession:appKey];
|
||||
}
|
||||
|
||||
- (void) stopSession
|
||||
{
|
||||
NSLog(@"stopSession in flurry not available on iOS");
|
||||
}
|
||||
|
||||
- (void) setSessionContinueMillis: (NSNumber*) millis
|
||||
{
|
||||
long lMillis = [millis longValue];
|
||||
int seconds = (int)(lMillis / 1000);
|
||||
[Flurry setSessionContinueSeconds:seconds];
|
||||
}
|
||||
|
||||
- (void) setCaptureUncaughtException: (NSNumber*) isEnabled
|
||||
{
|
||||
NSLog(@"setCaptureUncaughtException in flurry not available on iOS");
|
||||
}
|
||||
|
||||
- (void) setDebugMode: (NSNumber*) isDebugMode
|
||||
{
|
||||
BOOL bDebug = [isDebugMode boolValue];
|
||||
[Flurry setDebugLogEnabled:bDebug];
|
||||
}
|
||||
|
||||
- (void) logError: (NSString*) errorId withMsg:(NSString*) message
|
||||
{
|
||||
NSString* msg = nil;
|
||||
if (nil == message) {
|
||||
msg = @"";
|
||||
} else {
|
||||
msg = message;
|
||||
}
|
||||
[Flurry logError:errorId message:msg exception:nil];
|
||||
}
|
||||
|
||||
- (void) logEvent: (NSString*) eventId
|
||||
{
|
||||
[Flurry logEvent:eventId];
|
||||
}
|
||||
|
||||
- (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap
|
||||
{
|
||||
[Flurry logEvent:eventId withParameters:paramMap];
|
||||
}
|
||||
|
||||
- (void) logTimedEventBegin: (NSString*) eventId
|
||||
{
|
||||
[Flurry logEvent:eventId timed:YES];
|
||||
}
|
||||
|
||||
- (void) logTimedEventEnd: (NSString*) eventId
|
||||
{
|
||||
[Flurry endTimedEvent:eventId withParameters:nil];
|
||||
}
|
||||
|
||||
- (NSString*) getSDKVersion
|
||||
{
|
||||
return [Flurry getFlurryAgentVersion];
|
||||
}
|
||||
|
||||
- (void) setAge: (NSNumber*) age
|
||||
{
|
||||
int nAge = [age integerValue];
|
||||
[Flurry setAge:nAge];
|
||||
}
|
||||
|
||||
- (void) setGender: (NSString*) gender
|
||||
{
|
||||
[Flurry setGender:gender];
|
||||
}
|
||||
|
||||
- (void) setUserId: (NSString*) userId
|
||||
{
|
||||
[Flurry setUserID:userId];
|
||||
}
|
||||
|
||||
- (void) logPageView
|
||||
{
|
||||
[Flurry logPageView];
|
||||
}
|
||||
|
||||
- (void) setVersionName: (NSString*) versionName
|
||||
{
|
||||
[Flurry setAppVersion:versionName];
|
||||
}
|
||||
|
||||
- (void) logTimedEventBegin: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap
|
||||
{
|
||||
[Flurry logEvent:eventId withParameters:paramMap timed:YES];
|
||||
}
|
||||
|
||||
- (void) logTimedEventEnd: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap
|
||||
{
|
||||
[Flurry endTimedEvent:eventId withParameters:paramMap];
|
||||
}
|
||||
|
||||
@end
|
|
@ -10,6 +10,7 @@
|
|||
FA09A376168AFD41008C1C7B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA09A375168AFD41008C1C7B /* Foundation.framework */; };
|
||||
FA09A394168B00D4008C1C7B /* AnalyticsFlurry.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA09A393168B00D4008C1C7B /* AnalyticsFlurry.mm */; };
|
||||
FA866509168BE0980073E055 /* libFlurry.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA866508168BE0980073E055 /* libFlurry.a */; };
|
||||
FA8CC2241739EFF200464206 /* FlurryWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = FA8CC2231739EFF200464206 /* FlurryWrapper.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
|
@ -32,6 +33,8 @@
|
|||
FA866507168BE0980073E055 /* Flurry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Flurry.h; sourceTree = "<group>"; };
|
||||
FA866508168BE0980073E055 /* libFlurry.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libFlurry.a; sourceTree = "<group>"; };
|
||||
FA86650E168BE22D0073E055 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
|
||||
FA8CC2221739EFF200464206 /* FlurryWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlurryWrapper.h; sourceTree = "<group>"; };
|
||||
FA8CC2231739EFF200464206 /* FlurryWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FlurryWrapper.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -86,6 +89,8 @@
|
|||
FA09A392168AFD96008C1C7B /* ios */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FA8CC2221739EFF200464206 /* FlurryWrapper.h */,
|
||||
FA8CC2231739EFF200464206 /* FlurryWrapper.m */,
|
||||
FA866507168BE0980073E055 /* Flurry.h */,
|
||||
FA866508168BE0980073E055 /* libFlurry.a */,
|
||||
FA09A393168B00D4008C1C7B /* AnalyticsFlurry.mm */,
|
||||
|
@ -146,6 +151,7 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
FA09A394168B00D4008C1C7B /* AnalyticsFlurry.mm in Sources */,
|
||||
FA8CC2241739EFF200464206 /* FlurryWrapper.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -202,7 +208,10 @@
|
|||
DSTROOT = /tmp/libPluginFlurry.dst;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch";
|
||||
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/include";
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/../../../protocols/include",
|
||||
"$(SRCROOT)/../../../protocols/platform/ios",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/../platform/ios\"",
|
||||
|
@ -219,7 +228,10 @@
|
|||
DSTROOT = /tmp/libPluginFlurry.dst;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch";
|
||||
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/include";
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/../../../protocols/include",
|
||||
"$(SRCROOT)/../../../protocols/platform/ios",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/../platform/ios\"",
|
||||
|
|
|
@ -23,6 +23,7 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
#include "AnalyticsUmeng.h"
|
||||
#include "MobClick.h"
|
||||
#include "PluginUtilsIOS.h"
|
||||
|
||||
namespace cocos2d { namespace plugin {
|
||||
|
||||
|
@ -51,119 +52,96 @@ AnalyticsUmeng::~AnalyticsUmeng()
|
|||
|
||||
bool AnalyticsUmeng::init()
|
||||
{
|
||||
return true;
|
||||
return PluginUtilsIOS::initOCPlugin(this, "UmengWrapper");
|
||||
}
|
||||
|
||||
/** Start a new session. */
|
||||
void AnalyticsUmeng::startSession(const char* appKey)
|
||||
{
|
||||
if (NULL == appKey || strlen(appKey) == 0) {
|
||||
UmengLogD("appkey is invalid!");
|
||||
return;
|
||||
}
|
||||
NSString* pKey = [NSString stringWithUTF8String:appKey];
|
||||
[[MobClick class] performSelector:@selector(setWrapperType:wrapperVersion:) withObject:@"Cocos2d-x" withObject:@"1.0"];
|
||||
[MobClick startWithAppkey:pKey];
|
||||
ProtocolAnalytics::startSession(appKey);
|
||||
}
|
||||
|
||||
/** Stop a session. only worked on android */
|
||||
void AnalyticsUmeng::stopSession()
|
||||
{
|
||||
ProtocolAnalytics::stopSession();
|
||||
}
|
||||
|
||||
/** Set whether needs to output logs to console.*/
|
||||
void AnalyticsUmeng::setDebugMode(bool debug)
|
||||
{
|
||||
s_bDebugable = debug;
|
||||
[MobClick setLogEnabled:debug];
|
||||
ProtocolAnalytics::setDebugMode(debug);
|
||||
}
|
||||
|
||||
/** Set the timeout for expiring a session. */
|
||||
void AnalyticsUmeng::setSessionContinueMillis(long millis)
|
||||
{
|
||||
|
||||
ProtocolAnalytics::setSessionContinueMillis(millis);
|
||||
}
|
||||
|
||||
/** log an error */
|
||||
void AnalyticsUmeng::logError(const char* errorId, const char* message)
|
||||
{
|
||||
|
||||
ProtocolAnalytics::logError(errorId, message);
|
||||
}
|
||||
|
||||
/** log an event. */
|
||||
void AnalyticsUmeng::logEvent(const char* eventId, LogEventParamMap* paramMap)
|
||||
{
|
||||
if (NULL == eventId || strlen(eventId) == 0) {
|
||||
UmengLogD("eventId is invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
NSString* pId = [NSString stringWithUTF8String:eventId];
|
||||
if (NULL == paramMap) {
|
||||
[MobClick event:pId];
|
||||
} else {
|
||||
NSMutableDictionary* dict = [NSMutableDictionary dictionary];
|
||||
LogEventParamMap::iterator it;
|
||||
for (it = paramMap->begin(); it != paramMap->end(); it++) {
|
||||
std::string key = it->first;
|
||||
std::string value = it->second;
|
||||
NSString* pKey = [NSString stringWithUTF8String:key.c_str()];
|
||||
NSString* pValue = [NSString stringWithUTF8String:value.c_str()];
|
||||
[dict setObject:pValue forKey:pKey];
|
||||
}
|
||||
[MobClick event:pId attributes:dict];
|
||||
}
|
||||
ProtocolAnalytics::logEvent(eventId, paramMap);
|
||||
}
|
||||
|
||||
/** begin to log a timed event */
|
||||
void AnalyticsUmeng::logTimedEventBegin(const char* eventId)
|
||||
{
|
||||
if (NULL == eventId || strlen(eventId) == 0) {
|
||||
UmengLogD("eventId is invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
NSString* pEvent = [NSString stringWithUTF8String:eventId];
|
||||
[MobClick beginEvent:pEvent];
|
||||
ProtocolAnalytics::logTimedEventBegin(eventId);
|
||||
}
|
||||
|
||||
/** end a timed event */
|
||||
void AnalyticsUmeng::logTimedEventEnd(const char* eventId)
|
||||
{
|
||||
if (NULL == eventId || strlen(eventId) == 0) {
|
||||
UmengLogD("eventId is invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
NSString* pEvent = [NSString stringWithUTF8String:eventId];
|
||||
[MobClick endEvent:pEvent];
|
||||
ProtocolAnalytics::logTimedEventEnd(eventId);
|
||||
}
|
||||
|
||||
/** Whether to catch uncaught exceptions to server.*/
|
||||
void AnalyticsUmeng::setCaptureUncaughtException(bool enabled)
|
||||
{
|
||||
[MobClick setCrashReportEnabled:enabled];
|
||||
ProtocolAnalytics::setCaptureUncaughtException(enabled);
|
||||
}
|
||||
|
||||
const char* AnalyticsUmeng::getSDKVersion()
|
||||
{
|
||||
return "UMeng no version info";
|
||||
return ProtocolAnalytics::getSDKVersion();
|
||||
}
|
||||
|
||||
void AnalyticsUmeng::updateOnlineConfig()
|
||||
{
|
||||
[MobClick updateOnlineConfig];
|
||||
PluginUtilsIOS::callOCFunctionWithName(this, "updateOnlineConfig");
|
||||
}
|
||||
|
||||
const char* AnalyticsUmeng::getConfigParams(const char* key)
|
||||
{
|
||||
NSString* strKey = [NSString stringWithUTF8String:key];
|
||||
return [[MobClick getConfigParams:strKey] UTF8String];
|
||||
|
||||
|
||||
if (NULL == key || strlen(key) == 0) {
|
||||
UmengLogD("The key is invalid!");
|
||||
return "";
|
||||
}
|
||||
|
||||
NSString* pKey = [NSString stringWithUTF8String:key];
|
||||
NSString* ret = [MobClick getConfigParams:pKey];
|
||||
NSString* ret = nil;
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
if (pData) {
|
||||
id pOCObj = pData->obj;
|
||||
SEL selector = NSSelectorFromString(@"getConfigParams:");
|
||||
if ([pOCObj respondsToSelector:selector]) {
|
||||
ret = [pOCObj performSelector:selector withObject:pKey];
|
||||
}
|
||||
}
|
||||
|
||||
const char* pRet = (nil == ret) ? NULL : [ret UTF8String];
|
||||
return pRet;
|
||||
}
|
||||
|
@ -181,12 +159,15 @@ void AnalyticsUmeng::logEventWithLabel(const char* eventId, const char* label)
|
|||
return;
|
||||
}
|
||||
|
||||
NSString* pId = [NSString stringWithUTF8String:eventId];
|
||||
if (NULL == label) {
|
||||
[MobClick event:pId];
|
||||
} else {
|
||||
NSString* pLabel = [NSString stringWithUTF8String:label];
|
||||
[MobClick event:pId label:pLabel];
|
||||
NSString* strEvent = [NSString stringWithUTF8String:eventId];
|
||||
NSString* strLabel = [NSString stringWithUTF8String:label];
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
if (pData) {
|
||||
id pOCObj = pData->obj;
|
||||
SEL selector = NSSelectorFromString(@"logEvent:withLabel:");
|
||||
if ([pOCObj respondsToSelector:selector]) {
|
||||
[pOCObj performSelector:selector withObject:strEvent withObject:strLabel];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,13 +178,33 @@ void AnalyticsUmeng::logEventWithDuration(const char* eventId, long duration, co
|
|||
return;
|
||||
}
|
||||
|
||||
NSString* pId = [NSString stringWithUTF8String:eventId];
|
||||
if (NULL == label) {
|
||||
[MobClick event:pId durations:(int)duration];
|
||||
} else {
|
||||
NSString* pLabel = [NSString stringWithUTF8String:label];
|
||||
[MobClick event:pId label:pLabel durations:(int)duration];
|
||||
}
|
||||
do {
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
|
||||
if (! pData) break;
|
||||
|
||||
id pOCObj = pData->obj;
|
||||
NSString* className = [NSString stringWithUTF8String:pData->className.c_str()];
|
||||
SEL selector = NSSelectorFromString(@"logEvent:withDuration:withLabel:");
|
||||
|
||||
if (! [pOCObj respondsToSelector:selector]) {
|
||||
break;
|
||||
}
|
||||
|
||||
NSString* strEventId = [NSString stringWithUTF8String:eventId];
|
||||
NSString* strLabel = [NSString stringWithUTF8String:label];
|
||||
NSNumber* numDur = [NSNumber numberWithLong:duration];
|
||||
|
||||
NSMethodSignature *sig= [NSClassFromString(className) instanceMethodSignatureForSelector:selector];
|
||||
NSInvocation *invocation=[NSInvocation invocationWithMethodSignature:sig];
|
||||
[invocation setTarget:pOCObj];
|
||||
[invocation setSelector:selector];
|
||||
[invocation setArgument:&strEventId atIndex:2];
|
||||
[invocation setArgument:&numDur atIndex:3];
|
||||
[invocation setArgument:&strLabel atIndex:4];
|
||||
[invocation retainArguments];
|
||||
[invocation invoke];
|
||||
} while (0);
|
||||
}
|
||||
|
||||
void AnalyticsUmeng::logEventWithDuration(const char* eventId, long duration, LogEventParamMap* paramMap)
|
||||
|
@ -213,21 +214,33 @@ void AnalyticsUmeng::logEventWithDuration(const char* eventId, long duration, Lo
|
|||
return;
|
||||
}
|
||||
|
||||
NSString* pId = [NSString stringWithUTF8String:eventId];
|
||||
if (NULL == paramMap) {
|
||||
[MobClick event:pId durations:(int)duration];
|
||||
} else {
|
||||
NSMutableDictionary* dict = [NSMutableDictionary dictionary];
|
||||
LogEventParamMap::iterator it;
|
||||
for (it = paramMap->begin(); it != paramMap->end(); it++) {
|
||||
std::string key = it->first;
|
||||
std::string value = it->second;
|
||||
NSString* pKey = [NSString stringWithUTF8String:key.c_str()];
|
||||
NSString* pValue = [NSString stringWithUTF8String:value.c_str()];
|
||||
[dict setObject:pValue forKey:pKey];
|
||||
do {
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
|
||||
if (! pData) break;
|
||||
|
||||
id pOCObj = pData->obj;
|
||||
SEL selector = NSSelectorFromString(@"logEvent:withDuration:withParam:");
|
||||
|
||||
if (! [pOCObj respondsToSelector:selector]) {
|
||||
break;
|
||||
}
|
||||
[MobClick event:pId attributes:dict durations:(int)duration];
|
||||
}
|
||||
|
||||
NSString* strEventId = [NSString stringWithUTF8String:eventId];
|
||||
NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(paramMap);
|
||||
NSNumber* numDur = [NSNumber numberWithLong:duration];
|
||||
|
||||
NSMethodSignature *sig = [[pOCObj class] instanceMethodSignatureForSelector:selector];
|
||||
NSInvocation *invocation =[NSInvocation invocationWithMethodSignature:sig];
|
||||
|
||||
[invocation setSelector:selector];
|
||||
[invocation setTarget:pOCObj];
|
||||
[invocation setArgument:&strEventId atIndex:2];
|
||||
[invocation setArgument:&numDur atIndex:3];
|
||||
[invocation setArgument:&dict atIndex:4];
|
||||
[invocation retainArguments];
|
||||
[invocation invoke];
|
||||
} while (0);
|
||||
}
|
||||
|
||||
void AnalyticsUmeng::logTimedEventWithLabelBegin(const char* eventId, const char* label)
|
||||
|
@ -237,12 +250,15 @@ void AnalyticsUmeng::logTimedEventWithLabelBegin(const char* eventId, const char
|
|||
return;
|
||||
}
|
||||
|
||||
NSString* pId = [NSString stringWithUTF8String:eventId];
|
||||
if (NULL == label) {
|
||||
[MobClick beginEvent:pId];
|
||||
} else {
|
||||
NSString* pLabel = [NSString stringWithUTF8String:label];
|
||||
[MobClick beginEvent:pId label:pLabel];
|
||||
NSString* strEvent = [NSString stringWithUTF8String:eventId];
|
||||
NSString* strLabel = [NSString stringWithUTF8String:label];
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
if (pData) {
|
||||
id pOCObj = pData->obj;
|
||||
SEL selector = NSSelectorFromString(@"logTimedEventBegin:withLabel:");
|
||||
if ([pOCObj respondsToSelector:selector]) {
|
||||
[pOCObj performSelector:selector withObject:strEvent withObject:strLabel];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,12 +269,15 @@ void AnalyticsUmeng::logTimedEventWithLabelEnd(const char* eventId, const char*
|
|||
return;
|
||||
}
|
||||
|
||||
NSString* pId = [NSString stringWithUTF8String:eventId];
|
||||
if (NULL == label) {
|
||||
[MobClick endEvent:pId];
|
||||
} else {
|
||||
NSString* pLabel = [NSString stringWithUTF8String:label];
|
||||
[MobClick endEvent:pId label:pLabel];
|
||||
NSString* strEvent = [NSString stringWithUTF8String:eventId];
|
||||
NSString* strLabel = [NSString stringWithUTF8String:label];
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
if (pData) {
|
||||
id pOCObj = pData->obj;
|
||||
SEL selector = NSSelectorFromString(@"logTimedEventEnd:withLabel:");
|
||||
if ([pOCObj respondsToSelector:selector]) {
|
||||
[pOCObj performSelector:selector withObject:strEvent withObject:strLabel];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,22 +288,33 @@ void AnalyticsUmeng::logTimedKVEventBegin(const char* eventId, const char* label
|
|||
return;
|
||||
}
|
||||
|
||||
NSString* pId = [NSString stringWithUTF8String:eventId];
|
||||
NSString* primary = [NSString stringWithUTF8String:label];
|
||||
if (NULL == paramMap || NULL == label) {
|
||||
[MobClick beginEvent:pId];
|
||||
} else {
|
||||
NSMutableDictionary* dict = [NSMutableDictionary dictionary];
|
||||
LogEventParamMap::iterator it;
|
||||
for (it = paramMap->begin(); it != paramMap->end(); it++) {
|
||||
std::string key = it->first;
|
||||
std::string value = it->second;
|
||||
NSString* pKey = [NSString stringWithUTF8String:key.c_str()];
|
||||
NSString* pValue = [NSString stringWithUTF8String:value.c_str()];
|
||||
[dict setObject:pValue forKey:pKey];
|
||||
do {
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
|
||||
if (! pData) break;
|
||||
|
||||
id pOCObj = pData->obj;
|
||||
NSString* className = [NSString stringWithUTF8String:pData->className.c_str()];
|
||||
SEL selector = NSSelectorFromString(@"logTimedKVEventBegin:withLabel:withParam:");
|
||||
|
||||
if (! [pOCObj respondsToSelector:selector]) {
|
||||
break;
|
||||
}
|
||||
[MobClick beginEvent:pId primarykey:primary attributes:dict];
|
||||
}
|
||||
|
||||
NSString* strEventId = [NSString stringWithUTF8String:eventId];
|
||||
NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(paramMap);
|
||||
NSString* strLabel = [NSString stringWithUTF8String:label];
|
||||
|
||||
NSMethodSignature *sig= [NSClassFromString(className) instanceMethodSignatureForSelector:selector];
|
||||
NSInvocation *invocation=[NSInvocation invocationWithMethodSignature:sig];
|
||||
[invocation setTarget:pOCObj];
|
||||
[invocation setSelector:selector];
|
||||
[invocation setArgument:&strEventId atIndex:2];
|
||||
[invocation setArgument:&strLabel atIndex:3];
|
||||
[invocation setArgument:&dict atIndex:4];
|
||||
[invocation retainArguments];
|
||||
[invocation invoke];
|
||||
} while (0);
|
||||
}
|
||||
|
||||
void AnalyticsUmeng::logTimedKVEventEnd(const char* eventId, const char* label)
|
||||
|
@ -294,12 +324,15 @@ void AnalyticsUmeng::logTimedKVEventEnd(const char* eventId, const char* label)
|
|||
return;
|
||||
}
|
||||
|
||||
NSString* pId = [NSString stringWithUTF8String:eventId];
|
||||
if (NULL == label) {
|
||||
[MobClick endEvent:pId];
|
||||
} else {
|
||||
NSString* primary = [NSString stringWithUTF8String:label];
|
||||
[MobClick endEvent:pId primarykey:primary];
|
||||
NSString* strEvent = [NSString stringWithUTF8String:eventId];
|
||||
NSString* strLabel = [NSString stringWithUTF8String:label];
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
if (pData) {
|
||||
id pOCObj = pData->obj;
|
||||
SEL selector = NSSelectorFromString(@"logTimedKVEventEnd:withLabel:");
|
||||
if ([pOCObj respondsToSelector:selector]) {
|
||||
[pOCObj performSelector:selector withObject:strEvent withObject:strLabel];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,15 +343,38 @@ void AnalyticsUmeng::startSession(const char* appKey, UmengReportPolicy policy,
|
|||
return;
|
||||
}
|
||||
|
||||
NSString* key = [NSString stringWithUTF8String:appKey];
|
||||
NSString* channel = [NSString stringWithUTF8String:channelId];
|
||||
[[MobClick class] performSelector:@selector(setWrapperType:wrapperVersion:) withObject:@"Cocos2d-x" withObject:@"1.0"];
|
||||
[MobClick startWithAppkey:key reportPolicy:(ReportPolicy)policy channelId:channel];
|
||||
do {
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
|
||||
if (! pData) break;
|
||||
|
||||
id pOCObj = pData->obj;
|
||||
NSString* className = [NSString stringWithUTF8String:pData->className.c_str()];
|
||||
SEL selector = NSSelectorFromString(@"logTimedKVEventBegin:withLabel:withParam:");
|
||||
|
||||
if (! [pOCObj respondsToSelector:selector]) {
|
||||
break;
|
||||
}
|
||||
|
||||
NSString* strKey = [NSString stringWithUTF8String:appKey];
|
||||
NSNumber* numPolicy = [NSNumber numberWithInt:policy];
|
||||
NSString* strChannel = [NSString stringWithUTF8String:channelId];
|
||||
|
||||
NSMethodSignature *sig= [NSClassFromString(className) instanceMethodSignatureForSelector:selector];
|
||||
NSInvocation *invocation=[NSInvocation invocationWithMethodSignature:sig];
|
||||
[invocation setTarget:pOCObj];
|
||||
[invocation setSelector:selector];
|
||||
[invocation setArgument:&strKey atIndex:2];
|
||||
[invocation setArgument:&numPolicy atIndex:3];
|
||||
[invocation setArgument:&strChannel atIndex:4];
|
||||
[invocation retainArguments];
|
||||
[invocation invoke];
|
||||
} while (0);
|
||||
}
|
||||
|
||||
void AnalyticsUmeng::checkUpdate()
|
||||
{
|
||||
[MobClick checkUpdate];
|
||||
PluginUtilsIOS::callOCFunctionWithName(this, "checkUpdate");
|
||||
}
|
||||
|
||||
}} // namespace cocos2d { namespace plugin {
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2012-2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#import "InterfaceAnalytics.h"
|
||||
|
||||
@interface UmengWrapper : NSObject <InterfaceAnalytics>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
interfaces of protocol : InterfaceAnalytics
|
||||
*/
|
||||
- (void) startSession: (NSString*) appKey;
|
||||
- (void) stopSession;
|
||||
- (void) setSessionContinueMillis: (NSNumber*) millis;
|
||||
- (void) setCaptureUncaughtException: (NSNumber*) isEnabled;
|
||||
- (void) setDebugMode: (NSNumber*) isDebugMode;
|
||||
- (void) logError: (NSString*) errorId withMsg:(NSString*) message;
|
||||
- (void) logEvent: (NSString*) eventId;
|
||||
- (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap;
|
||||
- (void) logTimedEventBegin: (NSString*) eventId;
|
||||
- (void) logTimedEventEnd: (NSString*) eventId;
|
||||
- (NSString*) getSDKVersion;
|
||||
|
||||
/**
|
||||
interfaces of umeng SDK
|
||||
*/
|
||||
- (void) updateOnlineConfig;
|
||||
- (NSString*) getConfigParams: (NSString*) key;
|
||||
- (void) logEvent: (NSString*) eventId withLabel:(NSString*) label;
|
||||
- (void) logEvent: (NSString*) eventId withDuration: (NSNumber*) duration withLabel:(NSString*) label;
|
||||
- (void) logEvent: (NSString*) eventId withDuration: (NSNumber*) duration withParam:(NSMutableDictionary*) paramMap;
|
||||
- (void) logTimedEventBegin: (NSString*) eventId withLabel:(NSString*) label;
|
||||
- (void) logTimedEventEnd: (NSString*) eventId withLabel:(NSString*) label;
|
||||
- (void) logTimedKVEventBegin: (NSString*) eventId withLabel:(NSString*) label withParam:(NSMutableDictionary*) paramMap;
|
||||
- (void) logTimedKVEventEnd: (NSString*) eventId withLabel:(NSString*) label;
|
||||
- (void) startSession: (NSString*) appKey withPolicy:(NSNumber*) policy withChannel:(NSString*) channelId;
|
||||
- (void) checkUpdate;
|
||||
|
||||
@end
|
|
@ -0,0 +1,170 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2012-2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#import "UmengWrapper.h"
|
||||
#import "MobClick.h"
|
||||
|
||||
@implementation UmengWrapper
|
||||
|
||||
- (void) startSession: (NSString*) appKey
|
||||
{
|
||||
[[MobClick class] performSelector:@selector(setWrapperType:wrapperVersion:) withObject:@"Cocos2d-x" withObject:@"1.0"];
|
||||
[MobClick startWithAppkey:appKey];
|
||||
}
|
||||
|
||||
- (void) stopSession
|
||||
{
|
||||
NSLog(@"stopSession in umeng not available on iOS");
|
||||
}
|
||||
|
||||
- (void) setSessionContinueMillis: (NSNumber*) millis
|
||||
{
|
||||
NSLog(@"setSessionContinueMillis in umeng not available on iOS");
|
||||
}
|
||||
|
||||
- (void) setCaptureUncaughtException: (NSNumber*) isEnabled
|
||||
{
|
||||
BOOL bEnabled = [isEnabled boolValue];
|
||||
[MobClick setCrashReportEnabled:bEnabled];
|
||||
}
|
||||
|
||||
- (void) setDebugMode: (NSNumber*) isDebugMode
|
||||
{
|
||||
BOOL bDebug = [isDebugMode boolValue];
|
||||
[MobClick setLogEnabled:bDebug];
|
||||
}
|
||||
|
||||
- (void) logError: (NSString*) errorId withMsg:(NSString*) message
|
||||
{
|
||||
NSLog(@"logError in umeng not available on iOS");
|
||||
}
|
||||
|
||||
- (void) logEvent: (NSString*) eventId
|
||||
{
|
||||
[MobClick event:eventId];
|
||||
}
|
||||
|
||||
- (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap
|
||||
{
|
||||
[MobClick event:eventId attributes:paramMap];
|
||||
}
|
||||
|
||||
- (void) logTimedEventBegin: (NSString*) eventId
|
||||
{
|
||||
[MobClick beginEvent:eventId];
|
||||
}
|
||||
|
||||
- (void) logTimedEventEnd: (NSString*) eventId
|
||||
{
|
||||
[MobClick endEvent:eventId];
|
||||
}
|
||||
|
||||
- (NSString*) getSDKVersion
|
||||
{
|
||||
return @"UMeng no version info";
|
||||
}
|
||||
|
||||
- (void) updateOnlineConfig
|
||||
{
|
||||
[MobClick updateOnlineConfig];
|
||||
}
|
||||
|
||||
- (NSString*) getConfigParams: (NSString*) key
|
||||
{
|
||||
return [MobClick getConfigParams:key];
|
||||
}
|
||||
|
||||
- (void) logEvent: (NSString*) eventId withLabel:(NSString*) label
|
||||
{
|
||||
[MobClick event:eventId label:label];
|
||||
}
|
||||
|
||||
- (void) logEvent: (NSString*) eventId withDuration: (NSNumber*) duration withLabel:(NSString*) label
|
||||
{
|
||||
long numDur = [duration longValue];
|
||||
if (! label) {
|
||||
[MobClick event:eventId durations:numDur];
|
||||
} else {
|
||||
[MobClick event:eventId label:label durations:numDur];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) logEvent: (NSString*) eventId withDuration:(NSNumber*) duration withParam:(NSMutableDictionary*) paramMap
|
||||
{
|
||||
long numDur = [duration longValue];
|
||||
if (! paramMap) {
|
||||
[MobClick event:eventId durations:(int)numDur];
|
||||
} else {
|
||||
[MobClick event:eventId attributes:paramMap durations:(int)numDur];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) logTimedEventBegin: (NSString*) eventId withLabel:(NSString*) label
|
||||
{
|
||||
if (! label) {
|
||||
[MobClick beginEvent:eventId];
|
||||
} else {
|
||||
[MobClick beginEvent:eventId label:label];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) logTimedEventEnd: (NSString*) eventId withLabel:(NSString*) label
|
||||
{
|
||||
if (! label) {
|
||||
[MobClick endEvent:eventId];
|
||||
} else {
|
||||
[MobClick endEvent:eventId label:label];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) logTimedKVEventBegin: (NSString*) eventId withLabel:(NSString*) label withParam:(NSMutableDictionary*) paramMap
|
||||
{
|
||||
if (! label || ! paramMap) {
|
||||
[MobClick beginEvent:eventId];
|
||||
} else {
|
||||
[MobClick beginEvent:eventId primarykey:label attributes:paramMap];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) logTimedKVEventEnd: (NSString*) eventId withLabel:(NSString*) label
|
||||
{
|
||||
if (! label) {
|
||||
[MobClick endEvent:eventId];
|
||||
} else {
|
||||
[MobClick endEvent:eventId primarykey:label];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) startSession: (NSString*) appKey withPolicy:(NSNumber*) policy withChannel:(NSString*) channelId
|
||||
{
|
||||
int nPolicy = [policy intValue];
|
||||
[[MobClick class] performSelector:@selector(setWrapperType:wrapperVersion:) withObject:@"Cocos2d-x" withObject:@"1.0"];
|
||||
[MobClick startWithAppkey:appKey reportPolicy:(ReportPolicy)nPolicy channelId:channelId];
|
||||
}
|
||||
|
||||
- (void) checkUpdate
|
||||
{
|
||||
[MobClick checkUpdate];
|
||||
}
|
||||
|
||||
@end
|
|
@ -9,6 +9,7 @@
|
|||
/* Begin PBXBuildFile section */
|
||||
FA09A305168ADAEC008C1C7B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA09A304168ADAEC008C1C7B /* Foundation.framework */; };
|
||||
FA09A352168ADCA6008C1C7B /* AnalyticsUmeng.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA09A350168ADCA6008C1C7B /* AnalyticsUmeng.mm */; };
|
||||
FA42959E173A4B6500462EF7 /* UmengWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = FA42959D173A4B6500462EF7 /* UmengWrapper.m */; };
|
||||
FA866506168BE06A0073E055 /* libMobClickLibrary.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA866505168BE06A0073E055 /* libMobClickLibrary.a */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
@ -30,6 +31,8 @@
|
|||
FA09A34E168ADC97008C1C7B /* AnalyticsUmeng.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnalyticsUmeng.h; sourceTree = "<group>"; };
|
||||
FA09A350168ADCA6008C1C7B /* AnalyticsUmeng.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AnalyticsUmeng.mm; sourceTree = "<group>"; };
|
||||
FA09A351168ADCA6008C1C7B /* MobClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MobClick.h; sourceTree = "<group>"; };
|
||||
FA42959C173A4B6500462EF7 /* UmengWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UmengWrapper.h; sourceTree = "<group>"; };
|
||||
FA42959D173A4B6500462EF7 /* UmengWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UmengWrapper.m; sourceTree = "<group>"; };
|
||||
FA866505168BE06A0073E055 /* libMobClickLibrary.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libMobClickLibrary.a; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
|
@ -84,6 +87,8 @@
|
|||
FA09A34F168ADCA6008C1C7B /* ios */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FA42959C173A4B6500462EF7 /* UmengWrapper.h */,
|
||||
FA42959D173A4B6500462EF7 /* UmengWrapper.m */,
|
||||
FA866505168BE06A0073E055 /* libMobClickLibrary.a */,
|
||||
FA09A350168ADCA6008C1C7B /* AnalyticsUmeng.mm */,
|
||||
FA09A351168ADCA6008C1C7B /* MobClick.h */,
|
||||
|
@ -144,6 +149,7 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
FA09A352168ADCA6008C1C7B /* AnalyticsUmeng.mm in Sources */,
|
||||
FA42959E173A4B6500462EF7 /* UmengWrapper.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -200,7 +206,10 @@
|
|||
DSTROOT = /tmp/libPluginUmeng.dst;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch";
|
||||
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/include";
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/../../../protocols/include",
|
||||
"$(SRCROOT)/../../../protocols/platform/ios",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)\"",
|
||||
|
@ -218,7 +227,10 @@
|
|||
DSTROOT = /tmp/libPluginUmeng.dst;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch";
|
||||
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/include";
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/../../../protocols/include",
|
||||
"$(SRCROOT)/../../../protocols/platform/ios",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)\"",
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2012+2013 cocos2d+x.org
|
||||
|
||||
http://www.cocos2d+x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol InterfaceAds <NSObject>
|
||||
|
||||
- (void) configDeveloperInfo: (NSMutableDictionary*) devInfo;
|
||||
- (void) showAds: (int) type size:(int) sizeEnum position:(int) pos;
|
||||
- (void) hideAds: (NSNumber*) type;
|
||||
- (void) spendPoints: (NSNumber*) points;
|
||||
- (void) setDebugMode: (NSNumber*) debug;
|
||||
- (NSString*) getSDKVersion;
|
||||
|
||||
@end
|
|
@ -0,0 +1,41 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2012+2013 cocos2d+x.org
|
||||
|
||||
http://www.cocos2d+x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol InterfaceAnalytics <NSObject>
|
||||
|
||||
- (void) startSession: (NSString*) appKey;
|
||||
- (void) stopSession;
|
||||
- (void) setSessionContinueMillis: (NSNumber*) millis;
|
||||
- (void) setCaptureUncaughtException: (NSNumber*) isEnabled;
|
||||
- (void) setDebugMode: (NSNumber*) isDebugMode;
|
||||
- (void) logError: (NSString*) errorId withMsg:(NSString*) message;
|
||||
- (void) logEvent: (NSString*) eventId;
|
||||
- (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap;
|
||||
- (void) logTimedEventBegin: (NSString*) eventId;
|
||||
- (void) logTimedEventEnd: (NSString*) eventId;
|
||||
- (NSString*) getSDKVersion;
|
||||
|
||||
@end
|
|
@ -0,0 +1,34 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2012+2013 cocos2d+x.org
|
||||
|
||||
http://www.cocos2d+x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol InterfaceIAP <NSObject>
|
||||
|
||||
- (void) configDeveloperInfo: (NSMutableDictionary*) cpInfo;
|
||||
- (void) payForProduct: (NSMutableDictionary*) profuctInfo;
|
||||
- (void) setDebugMode: (NSNumber*) debug;
|
||||
- (NSString*) getSDKVersion;
|
||||
|
||||
@end
|
|
@ -0,0 +1,29 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2012+2013 cocos2d+x.org
|
||||
|
||||
http://www.cocos2d+x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
@protocol InterfaceSocial <NSObject>
|
||||
|
||||
|
||||
|
||||
@end
|
|
@ -0,0 +1,61 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2012+2013 cocos2d+x.org
|
||||
|
||||
http://www.cocos2d+x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __PLUGIN_UTILS_IOS_H__
|
||||
#define __PLUGIN_UTILS_IOS_H__
|
||||
|
||||
#include "PluginProtocol.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace cocos2d { namespace plugin {
|
||||
|
||||
#define return_if_fails(cond) if (!(cond)) return;
|
||||
#define return_val_if_fails(cond, ret) if(!(cond)) return (ret);
|
||||
|
||||
typedef struct _PluginOCData
|
||||
{
|
||||
id obj;
|
||||
std::string className;
|
||||
} PluginOCData;
|
||||
|
||||
class PluginUtilsIOS
|
||||
{
|
||||
public:
|
||||
static bool initOCPlugin(PluginProtocol* pPlugin, const char* className);
|
||||
|
||||
static PluginOCData* getPluginOCData(PluginProtocol* pKeyObj);
|
||||
static void setPluginOCData(PluginProtocol* pKeyObj, PluginOCData* pData);
|
||||
static void erasePluginOCData(PluginProtocol* pKeyObj);
|
||||
|
||||
static PluginProtocol* getPluginPtr(id obj);
|
||||
|
||||
static NSMutableDictionary* createDictFromMap(std::map<std::string, std::string>* paramMap);
|
||||
static void callOCFunctionWithName(PluginProtocol* pPlugin, const char* funcName);
|
||||
static void callOCFunctionWithName_Object(PluginProtocol* pPlugin, const char* funcName, id obj);
|
||||
};
|
||||
|
||||
}} // namespace cocos2d { namespace plugin {
|
||||
|
||||
#endif //__PLUGIN_UTILS_IOS_H__
|
|
@ -0,0 +1,174 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2012-2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "PluginUtilsIOS.h"
|
||||
#include <map>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
namespace cocos2d { namespace plugin {
|
||||
|
||||
static PluginProtocol* s_pPluginInstance = NULL;
|
||||
|
||||
bool PluginUtilsIOS::initOCPlugin(PluginProtocol* pPlugin, const char* className)
|
||||
{
|
||||
return_val_if_fails(className != NULL && strlen(className) > 0, false);
|
||||
bool bRet = false;
|
||||
|
||||
NSString* name = [NSString stringWithUTF8String:className];
|
||||
id obj = [[NSClassFromString(name) alloc] init];
|
||||
if (obj != nil)
|
||||
{
|
||||
PluginOCData* pData = new PluginOCData();
|
||||
pData->obj = obj;
|
||||
pData->className = className;
|
||||
PluginUtilsIOS::setPluginOCData(pPlugin, pData);
|
||||
bRet = true;
|
||||
}
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
std::map<PluginProtocol*, PluginOCData*> s_PluginOCObjMap;
|
||||
std::map<id, PluginProtocol*> s_OCObjPluginMap;
|
||||
|
||||
typedef std::map<PluginProtocol*, PluginOCData*>::iterator OCObjMapIter;
|
||||
typedef std::map<id, PluginProtocol*>::iterator OCObjPluginMapIter;
|
||||
|
||||
PluginOCData* PluginUtilsIOS::getPluginOCData(PluginProtocol* pKeyObj)
|
||||
{
|
||||
PluginOCData* ret = NULL;
|
||||
OCObjMapIter it = s_PluginOCObjMap.find(pKeyObj);
|
||||
if (it != s_PluginOCObjMap.end()) {
|
||||
ret = it->second;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
PluginProtocol* PluginUtilsIOS::getPluginPtr(id obj)
|
||||
{
|
||||
PluginProtocol* ret = NULL;
|
||||
OCObjPluginMapIter it = s_OCObjPluginMap.find(obj);
|
||||
if (it != s_OCObjPluginMap.end()) {
|
||||
ret = it->second;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void PluginUtilsIOS::setPluginOCData(PluginProtocol* pKeyObj, PluginOCData* pData)
|
||||
{
|
||||
erasePluginOCData(pKeyObj);
|
||||
s_PluginOCObjMap.insert(std::pair<PluginProtocol*, PluginOCData*>(pKeyObj, pData));
|
||||
s_OCObjPluginMap.insert(std::pair<id, PluginProtocol*>(pData->obj, pKeyObj));
|
||||
}
|
||||
|
||||
void PluginUtilsIOS::erasePluginOCData(PluginProtocol* pKeyObj)
|
||||
{
|
||||
OCObjMapIter it = s_PluginOCObjMap.find(pKeyObj);
|
||||
if (it != s_PluginOCObjMap.end()) {
|
||||
PluginOCData* pData = it->second;
|
||||
if (pData != NULL)
|
||||
{
|
||||
id jobj = pData->obj;
|
||||
|
||||
OCObjPluginMapIter pluginIt = s_OCObjPluginMap.find(jobj);
|
||||
if (pluginIt != s_OCObjPluginMap.end())
|
||||
{
|
||||
s_OCObjPluginMap.erase(pluginIt);
|
||||
}
|
||||
|
||||
[jobj release];
|
||||
delete pData;
|
||||
}
|
||||
s_PluginOCObjMap.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
NSMutableDictionary* PluginUtilsIOS::createDictFromMap(std::map<std::string, std::string>* paramMap)
|
||||
{
|
||||
if (NULL == paramMap)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSMutableDictionary* dict = [NSMutableDictionary dictionary];
|
||||
std::map<std::string, std::string>::const_iterator it;
|
||||
for (it = paramMap->begin(); it != paramMap->end(); ++it)
|
||||
{
|
||||
NSString* pKey = [NSString stringWithUTF8String:it->first.c_str()];
|
||||
NSString* pValue = [NSString stringWithUTF8String:it->second.c_str()];
|
||||
[dict setValue:pValue forKey:pKey];
|
||||
}
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
void PluginUtilsIOS::callOCFunctionWithName(PluginProtocol* pPlugin, const char* funcName)
|
||||
{
|
||||
return_if_fails(funcName != NULL && strlen(funcName) > 0);
|
||||
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(pPlugin);
|
||||
if (pData) {
|
||||
id pOCObj = pData->obj;
|
||||
NSString* strFuncName = [NSString stringWithUTF8String:funcName];
|
||||
SEL selector = NSSelectorFromString(strFuncName);
|
||||
|
||||
const char* className = class_getName([pOCObj class]);
|
||||
NSString* strClassName = [NSString stringWithUTF8String:className];
|
||||
if ([pOCObj respondsToSelector:selector]) {
|
||||
[pOCObj performSelector:selector];
|
||||
NSLog(@"Function '%@' in class '%@' invoked", strFuncName, strClassName);
|
||||
} else {
|
||||
NSLog(@"Can't find function '%@' in class '%@'", strFuncName, strClassName);
|
||||
}
|
||||
} else {
|
||||
printf("Can't find function '%s' in plugin %p", funcName, pPlugin);
|
||||
}
|
||||
}
|
||||
|
||||
void PluginUtilsIOS::callOCFunctionWithName_Object(PluginProtocol* pPlugin, const char* funcName, id obj)
|
||||
{
|
||||
return_if_fails(funcName != NULL && strlen(funcName) > 0);
|
||||
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(pPlugin);
|
||||
if (pData) {
|
||||
id pOCObj = pData->obj;
|
||||
NSString* strFuncName = [NSString stringWithUTF8String:funcName];
|
||||
SEL selector = NSSelectorFromString(strFuncName);
|
||||
|
||||
const char* className = class_getName([pOCObj class]);
|
||||
NSString* strClassName = [NSString stringWithUTF8String:className];
|
||||
if ([pOCObj respondsToSelector:selector]) {
|
||||
[pOCObj performSelector:selector withObject:obj];
|
||||
NSLog(@"Function '%@' in class '%@' invoked", strFuncName, strClassName);
|
||||
} else {
|
||||
NSLog(@"Can't find function '%@' in class '%@'", strFuncName, strClassName);
|
||||
}
|
||||
} else {
|
||||
printf("Can't find function '%s' in plugin %p", funcName, pPlugin);
|
||||
}
|
||||
}
|
||||
|
||||
}}// namespace cocos2d { namespace plugin {
|
|
@ -1,66 +0,0 @@
|
|||
#include "ProtocolAds.h"
|
||||
|
||||
namespace cocos2d { namespace plugin {
|
||||
|
||||
ProtocolAds::ProtocolAds()
|
||||
: m_pListener(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
ProtocolAds::~ProtocolAds()
|
||||
{
|
||||
}
|
||||
|
||||
bool ProtocolAds::init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void ProtocolAds::configDeveloperInfo(TAdsDeveloperInfo devInfo)
|
||||
{
|
||||
}
|
||||
|
||||
void ProtocolAds::showAds(AdsType type, int sizeEnum, AdsPos pos)
|
||||
{
|
||||
}
|
||||
|
||||
void ProtocolAds::hideAds(AdsType type)
|
||||
{
|
||||
}
|
||||
|
||||
void ProtocolAds::spendPoints(int points)
|
||||
{
|
||||
}
|
||||
|
||||
void ProtocolAds::setDebugMode(bool debug)
|
||||
{
|
||||
}
|
||||
|
||||
// For the callbak methods
|
||||
void ProtocolAds::setAdsListener(AdsListener* pListener)
|
||||
{
|
||||
m_pListener = pListener;
|
||||
}
|
||||
|
||||
void ProtocolAds::onAdsResult(AdsResultCode code, const char* msg)
|
||||
{
|
||||
if (m_pListener != NULL)
|
||||
{
|
||||
m_pListener->onAdsResult(code, msg);
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolAds::onPlayerGetPoints(int points)
|
||||
{
|
||||
if (m_pListener != NULL)
|
||||
{
|
||||
m_pListener->onPlayerGetPoints(this, points);
|
||||
}
|
||||
}
|
||||
|
||||
const char* ProtocolAds::getSDKVersion()
|
||||
{
|
||||
return "Subclass should override this interface";
|
||||
}
|
||||
|
||||
}} //namespace cocos2d { namespace plugin {
|
|
@ -0,0 +1,91 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2012+2013 cocos2d+x.org
|
||||
|
||||
http://www.cocos2d+x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "ProtocolAds.h"
|
||||
#import "InterfaceAds.h"
|
||||
|
||||
namespace cocos2d { namespace plugin {
|
||||
|
||||
ProtocolAds::ProtocolAds()
|
||||
: m_pListener(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
ProtocolAds::~ProtocolAds()
|
||||
{
|
||||
}
|
||||
|
||||
bool ProtocolAds::init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void ProtocolAds::configDeveloperInfo(TAdsDeveloperInfo devInfo)
|
||||
{
|
||||
}
|
||||
|
||||
void ProtocolAds::showAds(AdsType type, int sizeEnum, AdsPos pos)
|
||||
{
|
||||
}
|
||||
|
||||
void ProtocolAds::hideAds(AdsType type)
|
||||
{
|
||||
}
|
||||
|
||||
void ProtocolAds::spendPoints(int points)
|
||||
{
|
||||
}
|
||||
|
||||
void ProtocolAds::setDebugMode(bool debug)
|
||||
{
|
||||
}
|
||||
|
||||
// For the callbak methods
|
||||
void ProtocolAds::setAdsListener(AdsListener* pListener)
|
||||
{
|
||||
m_pListener = pListener;
|
||||
}
|
||||
|
||||
void ProtocolAds::onAdsResult(AdsResultCode code, const char* msg)
|
||||
{
|
||||
if (m_pListener != NULL)
|
||||
{
|
||||
m_pListener->onAdsResult(code, msg);
|
||||
}
|
||||
}
|
||||
|
||||
void ProtocolAds::onPlayerGetPoints(int points)
|
||||
{
|
||||
if (m_pListener != NULL)
|
||||
{
|
||||
m_pListener->onPlayerGetPoints(this, points);
|
||||
}
|
||||
}
|
||||
|
||||
const char* ProtocolAds::getSDKVersion()
|
||||
{
|
||||
return "Subclass should override this interface";
|
||||
}
|
||||
|
||||
}} //namespace cocos2d { namespace plugin {
|
|
@ -1,108 +0,0 @@
|
|||
#include "ProtocolAnalytics.h"
|
||||
|
||||
namespace cocos2d { namespace plugin {
|
||||
|
||||
ProtocolAnalytics::ProtocolAnalytics()
|
||||
{
|
||||
}
|
||||
|
||||
ProtocolAnalytics::~ProtocolAnalytics()
|
||||
{
|
||||
}
|
||||
|
||||
bool ProtocolAnalytics::init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Start a new session.
|
||||
@param appKey The identity of the application.
|
||||
*/
|
||||
void ProtocolAnalytics::startSession(const char* appKey)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Stop a session.
|
||||
@warning This interface only worked on android
|
||||
*/
|
||||
void ProtocolAnalytics::stopSession()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Set whether needs to output logs to console.
|
||||
@param debug if true debug mode enabled, or debug mode disabled.
|
||||
@note It must be invoked before calling startSession.
|
||||
*/
|
||||
void ProtocolAnalytics::setDebugMode(bool debug)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Set the timeout for expiring a session.
|
||||
@param millis In milliseconds as the unit of time.
|
||||
@note It must be invoked before calling startSession.
|
||||
*/
|
||||
void ProtocolAnalytics::setSessionContinueMillis(long millis)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@brief log an error
|
||||
@param errorId The identity of error
|
||||
@param message Extern message for the error
|
||||
*/
|
||||
void ProtocolAnalytics::logError(const char* errorId, const char* message)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@brief log an event.
|
||||
@param eventId The identity of event
|
||||
@param paramMap Extern parameters of the event, use NULL if not needed.
|
||||
*/
|
||||
void ProtocolAnalytics::logEvent(const char* eventId, LogEventParamMap* paramMap)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Track an event begin.
|
||||
@param eventId The identity of event
|
||||
*/
|
||||
void ProtocolAnalytics::logTimedEventBegin(const char* eventId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Track an event end.
|
||||
@param eventId The identity of event
|
||||
*/
|
||||
void ProtocolAnalytics::logTimedEventEnd(const char* eventId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Whether to catch uncaught exceptions to server.
|
||||
@warning This interface only worked on android.
|
||||
*/
|
||||
void ProtocolAnalytics::setCaptureUncaughtException(bool enabled)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const char* ProtocolAnalytics::getSDKVersion()
|
||||
{
|
||||
return "Subclass should override this interface";
|
||||
}
|
||||
|
||||
}} //namespace cocos2d { namespace plugin {
|
|
@ -0,0 +1,186 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2012+2013 cocos2d+x.org
|
||||
|
||||
http://www.cocos2d+x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#include "ProtocolAnalytics.h"
|
||||
#import "InterfaceAnalytics.h"
|
||||
#include "PluginUtilsIOS.h"
|
||||
|
||||
namespace cocos2d { namespace plugin {
|
||||
|
||||
ProtocolAnalytics::ProtocolAnalytics()
|
||||
{
|
||||
}
|
||||
|
||||
ProtocolAnalytics::~ProtocolAnalytics()
|
||||
{
|
||||
PluginUtilsIOS::erasePluginOCData(this);
|
||||
}
|
||||
|
||||
bool ProtocolAnalytics::init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Start a new session.
|
||||
@param appKey The identity of the application.
|
||||
*/
|
||||
void ProtocolAnalytics::startSession(const char* appKey)
|
||||
{
|
||||
NSString* pStrKey = [NSString stringWithUTF8String:appKey];
|
||||
PluginUtilsIOS::callOCFunctionWithName_Object(this, "startSession:", pStrKey);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Stop a session.
|
||||
@warning This interface only worked on android
|
||||
*/
|
||||
void ProtocolAnalytics::stopSession()
|
||||
{
|
||||
PluginUtilsIOS::callOCFunctionWithName(this, "stopSession");
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Set whether needs to output logs to console.
|
||||
@param debug if true debug mode enabled, or debug mode disabled.
|
||||
@note It must be invoked before calling startSession.
|
||||
*/
|
||||
void ProtocolAnalytics::setDebugMode(bool debug)
|
||||
{
|
||||
NSNumber* bDebug = [NSNumber numberWithBool:debug];
|
||||
PluginUtilsIOS::callOCFunctionWithName_Object(this, "setDebugMode:", bDebug);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Set the timeout for expiring a session.
|
||||
@param millis In milliseconds as the unit of time.
|
||||
@note It must be invoked before calling startSession.
|
||||
*/
|
||||
void ProtocolAnalytics::setSessionContinueMillis(long millis)
|
||||
{
|
||||
NSNumber* lMillis = [NSNumber numberWithLong:millis];
|
||||
PluginUtilsIOS::callOCFunctionWithName_Object(this, "setSessionContinueMillis:", lMillis);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief log an error
|
||||
@param errorId The identity of error
|
||||
@param message Extern message for the error
|
||||
*/
|
||||
void ProtocolAnalytics::logError(const char* errorId, const char* message)
|
||||
{
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
if (! pData) {
|
||||
return;
|
||||
}
|
||||
|
||||
id pOCObj = pData->obj;
|
||||
SEL selector = NSSelectorFromString(@"logError:withMsg:");
|
||||
if ([pOCObj respondsToSelector:selector]) {
|
||||
|
||||
NSString* strErrID = [NSString stringWithUTF8String:errorId];
|
||||
NSString* strMsg = [NSString stringWithUTF8String:message];
|
||||
[pOCObj logError:strErrID withMsg:strMsg];
|
||||
NSLog(@"logError withMsg in OC class invoked!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief log an event.
|
||||
@param eventId The identity of event
|
||||
@param paramMap Extern parameters of the event, use NULL if not needed.
|
||||
*/
|
||||
void ProtocolAnalytics::logEvent(const char* eventId, LogEventParamMap* paramMap)
|
||||
{
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
if (! pData) {
|
||||
return;
|
||||
}
|
||||
|
||||
id pOCObj = pData->obj;
|
||||
NSString* strEventID = [NSString stringWithUTF8String:eventId];
|
||||
|
||||
if (paramMap == NULL) {
|
||||
PluginUtilsIOS::callOCFunctionWithName_Object(this, "logEvent:", strEventID);
|
||||
NSLog(@"logEvent(no paramsters) in OC class invoked!");
|
||||
} else {
|
||||
SEL selector = NSSelectorFromString(@"logEvent:withParam:");
|
||||
if ([pOCObj respondsToSelector:selector]) {
|
||||
|
||||
NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(paramMap);
|
||||
[pOCObj logEvent:strEventID withParam:dict];
|
||||
NSLog(@"logEvent(with parameters) in OC class invoked!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Track an event begin.
|
||||
@param eventId The identity of event
|
||||
*/
|
||||
void ProtocolAnalytics::logTimedEventBegin(const char* eventId)
|
||||
{
|
||||
NSString* pStrID = [NSString stringWithUTF8String:eventId];
|
||||
PluginUtilsIOS::callOCFunctionWithName_Object(this, "logTimedEventBegin:", pStrID);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Track an event end.
|
||||
@param eventId The identity of event
|
||||
*/
|
||||
void ProtocolAnalytics::logTimedEventEnd(const char* eventId)
|
||||
{
|
||||
NSString* pStrID = [NSString stringWithUTF8String:eventId];
|
||||
PluginUtilsIOS::callOCFunctionWithName_Object(this, "logTimedEventEnd:", pStrID);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Whether to catch uncaught exceptions to server.
|
||||
@warning This interface only worked on android.
|
||||
*/
|
||||
void ProtocolAnalytics::setCaptureUncaughtException(bool enabled)
|
||||
{
|
||||
NSNumber* bEnable = [NSNumber numberWithBool:enabled];
|
||||
PluginUtilsIOS::callOCFunctionWithName_Object(this, "setCaptureUncaughtException:", bEnable);
|
||||
}
|
||||
|
||||
const char* ProtocolAnalytics::getSDKVersion()
|
||||
{
|
||||
const char* pRet = "";
|
||||
|
||||
do {
|
||||
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
|
||||
if (! pData) break;
|
||||
|
||||
id pOCObj = pData->obj;
|
||||
SEL selector = NSSelectorFromString(@"getSDKVersion");
|
||||
if ([pOCObj respondsToSelector:selector]) {
|
||||
NSString* strRet = [pOCObj performSelector:selector];
|
||||
pRet = [strRet UTF8String];
|
||||
}
|
||||
} while (0);
|
||||
|
||||
return pRet;
|
||||
}
|
||||
|
||||
}} //namespace cocos2d { namespace plugin {
|
|
@ -1,54 +0,0 @@
|
|||
#include "ProtocolIAP.h"
|
||||
|
||||
namespace cocos2d { namespace plugin {
|
||||
|
||||
bool ProtocolIAP::m_bPaying = false;
|
||||
|
||||
ProtocolIAP::ProtocolIAP()
|
||||
: m_pListener(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
ProtocolIAP::~ProtocolIAP()
|
||||
{
|
||||
}
|
||||
|
||||
bool ProtocolIAP::init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void ProtocolIAP::configDeveloperInfo(TIAPDeveloperInfo devInfo)
|
||||
{
|
||||
}
|
||||
|
||||
void ProtocolIAP::payForProduct(TProductInfo info)
|
||||
{
|
||||
}
|
||||
|
||||
void ProtocolIAP::setResultListener(PayResultListener* pListener)
|
||||
{
|
||||
m_pListener = pListener;
|
||||
}
|
||||
|
||||
void ProtocolIAP::onPayResult(PayResultCode ret, const char* msg)
|
||||
{
|
||||
m_bPaying = false;
|
||||
if (m_pListener)
|
||||
{
|
||||
m_pListener->onPayResult(ret, msg, m_curInfo);
|
||||
}
|
||||
|
||||
m_curInfo.clear();
|
||||
}
|
||||
|
||||
const char* ProtocolIAP::getSDKVersion()
|
||||
{
|
||||
return "Subclass should override this interface";
|
||||
}
|
||||
|
||||
void ProtocolIAP::setDebugMode(bool debug)
|
||||
{
|
||||
}
|
||||
|
||||
}} //namespace cocos2d { namespace plugin {
|
|
@ -0,0 +1,80 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2012-2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#include "ProtocolIAP.h"
|
||||
#include "PluginUtilsIOS.h"
|
||||
#import "InterfaceIAP.h"
|
||||
|
||||
namespace cocos2d { namespace plugin {
|
||||
|
||||
bool ProtocolIAP::m_bPaying = false;
|
||||
|
||||
ProtocolIAP::ProtocolIAP()
|
||||
: m_pListener(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
ProtocolIAP::~ProtocolIAP()
|
||||
{
|
||||
PluginUtilsIOS::erasePluginOCData(this);
|
||||
}
|
||||
|
||||
bool ProtocolIAP::init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void ProtocolIAP::configDeveloperInfo(TIAPDeveloperInfo devInfo)
|
||||
{
|
||||
}
|
||||
|
||||
void ProtocolIAP::payForProduct(TProductInfo info)
|
||||
{
|
||||
}
|
||||
|
||||
void ProtocolIAP::setResultListener(PayResultListener* pListener)
|
||||
{
|
||||
m_pListener = pListener;
|
||||
}
|
||||
|
||||
void ProtocolIAP::onPayResult(PayResultCode ret, const char* msg)
|
||||
{
|
||||
m_bPaying = false;
|
||||
if (m_pListener)
|
||||
{
|
||||
m_pListener->onPayResult(ret, msg, m_curInfo);
|
||||
}
|
||||
|
||||
m_curInfo.clear();
|
||||
}
|
||||
|
||||
const char* ProtocolIAP::getSDKVersion()
|
||||
{
|
||||
return "Subclass should override this interface";
|
||||
}
|
||||
|
||||
void ProtocolIAP::setDebugMode(bool debug)
|
||||
{
|
||||
}
|
||||
|
||||
}} //namespace cocos2d { namespace plugin {
|
|
@ -10,9 +10,11 @@
|
|||
FA09A325168ADBC2008C1C7B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA09A324168ADBC2008C1C7B /* Foundation.framework */; };
|
||||
FA09A33E168ADC1F008C1C7B /* PluginManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA09A33C168ADC1F008C1C7B /* PluginManager.cpp */; };
|
||||
FA09A33F168ADC1F008C1C7B /* RegisterPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA09A33D168ADC1F008C1C7B /* RegisterPlugin.cpp */; };
|
||||
FA0CB8B7168D3CC200E36B11 /* ProtocolAnalytics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0CB8B6168D3CC200E36B11 /* ProtocolAnalytics.cpp */; };
|
||||
FA7C6C9B1724E51C008A0ECC /* ProtocolAds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA7C6C991724E51C008A0ECC /* ProtocolAds.cpp */; };
|
||||
FA7C6C9C1724E51C008A0ECC /* ProtocolIAP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA7C6C9A1724E51C008A0ECC /* ProtocolIAP.cpp */; };
|
||||
FA8CC1E6173754CF00464206 /* PluginUtilsIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA8CC1E5173754CF00464206 /* PluginUtilsIOS.mm */; };
|
||||
FA8CC2041737A3CE00464206 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8CC2031737A3CE00464206 /* CoreFoundation.framework */; };
|
||||
FA8CC208173894F000464206 /* ProtocolAds.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA8CC205173894F000464206 /* ProtocolAds.mm */; };
|
||||
FA8CC209173894F000464206 /* ProtocolAnalytics.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA8CC206173894F000464206 /* ProtocolAnalytics.mm */; };
|
||||
FA8CC20A173894F000464206 /* ProtocolIAP.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA8CC207173894F000464206 /* ProtocolIAP.mm */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
|
@ -37,11 +39,18 @@
|
|||
FA09A33B168ADC05008C1C7B /* RegisterPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterPlugin.h; sourceTree = "<group>"; };
|
||||
FA09A33C168ADC1F008C1C7B /* PluginManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PluginManager.cpp; path = ../PluginManager.cpp; sourceTree = "<group>"; };
|
||||
FA09A33D168ADC1F008C1C7B /* RegisterPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterPlugin.cpp; path = ../RegisterPlugin.cpp; sourceTree = "<group>"; };
|
||||
FA0CB8B6168D3CC200E36B11 /* ProtocolAnalytics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProtocolAnalytics.cpp; sourceTree = "<group>"; };
|
||||
FA4E3033172BD02800A3E673 /* ProtocolSocial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProtocolSocial.h; sourceTree = "<group>"; };
|
||||
FA7C6C971724E4DD008A0ECC /* ProtocolAds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProtocolAds.h; sourceTree = "<group>"; };
|
||||
FA7C6C991724E51C008A0ECC /* ProtocolAds.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProtocolAds.cpp; sourceTree = "<group>"; };
|
||||
FA7C6C9A1724E51C008A0ECC /* ProtocolIAP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProtocolIAP.cpp; sourceTree = "<group>"; };
|
||||
FA8CC1E4173754CF00464206 /* PluginUtilsIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginUtilsIOS.h; sourceTree = "<group>"; };
|
||||
FA8CC1E5173754CF00464206 /* PluginUtilsIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginUtilsIOS.mm; sourceTree = "<group>"; };
|
||||
FA8CC2031737A3CE00464206 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
|
||||
FA8CC205173894F000464206 /* ProtocolAds.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProtocolAds.mm; sourceTree = "<group>"; };
|
||||
FA8CC206173894F000464206 /* ProtocolAnalytics.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProtocolAnalytics.mm; sourceTree = "<group>"; };
|
||||
FA8CC207173894F000464206 /* ProtocolIAP.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProtocolIAP.mm; sourceTree = "<group>"; };
|
||||
FA8CC21B1739E86E00464206 /* InterfaceAds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InterfaceAds.h; sourceTree = "<group>"; };
|
||||
FA8CC21C1739E86E00464206 /* InterfaceAnalytics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InterfaceAnalytics.h; sourceTree = "<group>"; };
|
||||
FA8CC21D1739E86E00464206 /* InterfaceIAP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InterfaceIAP.h; sourceTree = "<group>"; };
|
||||
FA8CC21E1739E86E00464206 /* InterfaceSocial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InterfaceSocial.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -49,6 +58,7 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
FA8CC2041737A3CE00464206 /* CoreFoundation.framework in Frameworks */,
|
||||
FA09A325168ADBC2008C1C7B /* Foundation.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -59,6 +69,7 @@
|
|||
FA09A316168ADBC2008C1C7B = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FA8CC2031737A3CE00464206 /* CoreFoundation.framework */,
|
||||
FA0CB8B5168D3CC200E36B11 /* ios */,
|
||||
FA09A33C168ADC1F008C1C7B /* PluginManager.cpp */,
|
||||
FA09A33D168ADC1F008C1C7B /* RegisterPlugin.cpp */,
|
||||
|
@ -102,9 +113,15 @@
|
|||
FA0CB8B5168D3CC200E36B11 /* ios */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FA7C6C991724E51C008A0ECC /* ProtocolAds.cpp */,
|
||||
FA7C6C9A1724E51C008A0ECC /* ProtocolIAP.cpp */,
|
||||
FA0CB8B6168D3CC200E36B11 /* ProtocolAnalytics.cpp */,
|
||||
FA8CC21B1739E86E00464206 /* InterfaceAds.h */,
|
||||
FA8CC21C1739E86E00464206 /* InterfaceAnalytics.h */,
|
||||
FA8CC21D1739E86E00464206 /* InterfaceIAP.h */,
|
||||
FA8CC21E1739E86E00464206 /* InterfaceSocial.h */,
|
||||
FA8CC205173894F000464206 /* ProtocolAds.mm */,
|
||||
FA8CC206173894F000464206 /* ProtocolAnalytics.mm */,
|
||||
FA8CC207173894F000464206 /* ProtocolIAP.mm */,
|
||||
FA8CC1E4173754CF00464206 /* PluginUtilsIOS.h */,
|
||||
FA8CC1E5173754CF00464206 /* PluginUtilsIOS.mm */,
|
||||
);
|
||||
name = ios;
|
||||
path = ../platform/ios;
|
||||
|
@ -163,9 +180,10 @@
|
|||
files = (
|
||||
FA09A33E168ADC1F008C1C7B /* PluginManager.cpp in Sources */,
|
||||
FA09A33F168ADC1F008C1C7B /* RegisterPlugin.cpp in Sources */,
|
||||
FA0CB8B7168D3CC200E36B11 /* ProtocolAnalytics.cpp in Sources */,
|
||||
FA7C6C9B1724E51C008A0ECC /* ProtocolAds.cpp in Sources */,
|
||||
FA7C6C9C1724E51C008A0ECC /* ProtocolIAP.cpp in Sources */,
|
||||
FA8CC1E6173754CF00464206 /* PluginUtilsIOS.mm in Sources */,
|
||||
FA8CC208173894F000464206 /* ProtocolAds.mm in Sources */,
|
||||
FA8CC209173894F000464206 /* ProtocolAnalytics.mm in Sources */,
|
||||
FA8CC20A173894F000464206 /* ProtocolIAP.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -86,6 +86,10 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
g_pAnalytics->setDebugMode(true);
|
||||
g_pAnalytics->startSession(s_strAppKey.c_str());
|
||||
g_pAnalytics->setCaptureUncaughtException(true);
|
||||
g_pAnalytics->setSessionContinueMillis(10000);
|
||||
|
||||
const char* sdkVer = g_pAnalytics->getSDKVersion();
|
||||
CCLog("SDK version : %s", sdkVer);
|
||||
|
||||
AnalyticsUmeng* pUmeng = dynamic_cast<AnalyticsUmeng*>(g_pAnalytics);
|
||||
AnalyticsFlurry* pFlurry = dynamic_cast<AnalyticsFlurry*>(g_pAnalytics);
|
||||
|
|
|
@ -465,6 +465,7 @@
|
|||
"\"$(SRCROOT)/../../../plugins/flurry/platform/ios\"",
|
||||
"\"$(SRCROOT)/../../../plugins/umeng/platform/ios\"",
|
||||
);
|
||||
"OTHER_LDFLAGS[arch=*]" = "-ObjC";
|
||||
PRODUCT_NAME = HelloAnalytics;
|
||||
PROVISIONING_PROFILE = "";
|
||||
SDKROOT = iphoneos;
|
||||
|
@ -508,6 +509,7 @@
|
|||
"\"$(SRCROOT)/../../../plugins/flurry/platform/ios\"",
|
||||
"\"$(SRCROOT)/../../../plugins/umeng/platform/ios\"",
|
||||
);
|
||||
"OTHER_LDFLAGS[arch=*]" = "-ObjC";
|
||||
PRODUCT_NAME = HelloAnalytics;
|
||||
PROVISIONING_PROFILE = "";
|
||||
SDKROOT = iphoneos;
|
||||
|
|
Loading…
Reference in New Issue