Skip to content

Commit

Permalink
over event
Browse files Browse the repository at this point in the history
  • Loading branch information
pchonat committed Aug 11, 2020
1 parent a43fb69 commit 82d81c0
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 150 deletions.
2 changes: 1 addition & 1 deletion TestProject/Assets/Plugins/IOS/AdjustHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface AdjustHelper : NSObject
+(id)sharedInstance;
-(void)InitSDK:(id<cDelegate>)Delegate;
-(void)Event:(const char*) jsonData;
-(void)Event:(const char*) jsonString;
-(void)commonEvent:(NSString *)evnetToken;
-(void)purchaseEvent:(NSString *)appleOrderID;
@end
Expand Down
17 changes: 5 additions & 12 deletions TestProject/Assets/Plugins/IOS/AdjustHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ +(AdjustHelper*)sharedInstance{
}
-(void)InitSDK:(id<cDelegate>)Delegate{
IOSBridgeHelper = Delegate;
//点击游戏图标,启动游戏后,触发该事件 //ad启动统计
[self commonEvent:@"4pvqgy"];
}
-(void)Event:(const char*) jsonData{

-(void)Event:(const char*) jsonString{
NSString *evnetToken = [NSString stringWithUTF8String:jsonString];
[self commonEvent:evnetToken];
}
#pragma mark --上报普通事件
-(void)commonEvent:(NSString *)evnetToken{
Expand All @@ -42,16 +45,6 @@ -(void)purchaseEvent:(NSString *)appleOrderID{
[Adjust trackEvent:event];
// [[AdjustHelper sharedInstance] purchaseEvent:@"q5u2a6" andRevenue:&test andCurrency:currency];
}


//-(void)purchaseEvent:(NSString *)evnetToken andRevenue:(double * _Nonnull)revenue andCurrency:(NSString *)currencyName{
// ADJEvent *event = [ADJEvent eventWithEventToken:evnetToken];
//
////MOP澳门币 CNY人名币 EUR欧元 GBP英镑 HKD港元 JPY日元 KRW 韩元 THB泰铢 TWD新台币 VND越南盾 AUD 澳元
// [event setRevenue:*revenue currency:currencyName];
// [event setTransactionId:@"AppleOrderID"]; // avoid duplicates
// [Adjust trackEvent:event];
//}
#pragma mark --游戏启动登陆事件
-(void)launchEvent{
ADJEvent *event = [ADJEvent eventWithEventToken:@"4pvqgy"];
Expand Down
11 changes: 8 additions & 3 deletions TestProject/Assets/Plugins/IOS/ApplePurchase.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#import "ApplePurchase.h"
#import "Utils.h"
#import "AdjustHelper.h"
#import "FBHelper.h"
@implementation ApplePurchase{
NSString *curServiceName; //保存的名称集
NSString *goodID; //商品ID
Expand Down Expand Up @@ -185,13 +186,12 @@ - (void)paymentQueue:(nonnull SKPaymentQueue *)queue updatedTransactions:(nonnul
NSLog(@"交易完成 productIdentifier-->%@",tran.payment.productIdentifier);
NSLog(@"交易完成 transactionIdentifier-->%@",tran.transactionIdentifier);
NSLog(@"交易完成 applicationUsername-->%@",tran.payment.applicationUsername);

//支付统计
[[AdjustHelper sharedInstance] purchaseEvent:tran.transactionIdentifier];

// 发送自己服务器验证凭证
// [[SKPaymentQueue defaultQueue] finishTransaction:tran];
// [self deleteExtraWithPID:tran.payment.productIdentifier];
count = count + 1;
[self eventpurchase:tran];
[self HandleAppleOrder:tran];
break;
case SKPaymentTransactionStatePurchasing: // 购买中
Expand Down Expand Up @@ -226,6 +226,11 @@ - (void)paymentQueue:(nonnull SKPaymentQueue *)queue updatedTransactions:(nonnul
[self HandleReceipt];
}
}
//支付统计
-(void)eventpurchase:(SKPaymentTransaction *)transaction{
[[AdjustHelper sharedInstance] purchaseEvent:transaction.transactionIdentifier];
[[FBHelper sharedInstance] purchaseEvent:transaction.transactionIdentifier AndProductID:transaction.payment.productIdentifier];
}
//预处理并统计Apple订单
-(void)HandleAppleOrder:(SKPaymentTransaction *)transaction{
NSLog(@"--预处理并统计Apple订单---");
Expand Down
2 changes: 1 addition & 1 deletion TestProject/Assets/Plugins/IOS/ElvaHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface ElvaHelper : NSObject
+(id)sharedInstance;
-(void)InitSDK:(id<cDelegate>)Delegate;
-(void)show:(const char*) jsonData;
-(void)show:(const char*) jsonString;
@end

NS_ASSUME_NONNULL_END
166 changes: 62 additions & 104 deletions TestProject/Assets/Plugins/IOS/ElvaHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
#import "ElvaHelper.h"

@implementation ElvaHelper{
NSString *playerName;
NSString *playerUid;
NSString *serverId;
NSString *playerParseId;
NSString *showConversationFlag;
id IOSBridgeHelper;
}
static ElvaHelper *ElvaHelperIns = nil;
Expand All @@ -19,127 +24,80 @@ +(ElvaHelper*)sharedInstance{
}
-(void)InitSDK:(id)delegate{
IOSBridgeHelper = delegate;
NSString *AIHelpAppID = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"AIHelpAppID"];
NSString *AIHelpAppKey = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"AIHelpAppKey"];
NSString *AIHelpDomain = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"AIHelpDomain"];

[ECServiceSdk setUserName:@"UserName-PLAYER_NAME"]; //需要调用此方法
[ECServiceSdk setUserId:@"UserId-123ABC567DEF"]; //需要调用此方法
[ECServiceSdk setName:@"Girl for the Throne TW"];
[ECServiceSdk setServerId:@"ServerId-123456987456"];
[ECServiceSdk setSDKLanguage:@"zh_CN"];
// [ECServiceSdk setSDKLanguage:@"en"];
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString *AIHelpAppID = [infoDictionary objectForKey:@"AIHelpAppID"];
NSString *AIHelpAppKey = [infoDictionary objectForKey:@"AIHelpAppKey"];
NSString *AIHelpDomain = [infoDictionary objectForKey:@"AIHelpDomain"];
[ECServiceSdk setSDKInterfaceOrientationMask:UIInterfaceOrientationMaskPortrait];
[ECServiceSdk init:AIHelpAppKey Domain:AIHelpDomain AppId:AIHelpAppID];
[ECServiceSdk init:AIHelpAppKey Domain:AIHelpDomain AppId:AIHelpAppID];
playerParseId = @"";
// [ECServiceSdk setName:@"少女的王座"];
// [ECServiceSdk setServerId:@"ServerId-123456987456"];
// [ECServiceSdk setSDKLanguage:@"zh_TW"];
// [ECServiceSdk setSDKLanguage:@"zh_en"];
// [ECServiceSdk setSDKLanguage:@"zh_CN"];

}
#pragma mark --入口
-(void)show:(const char*) jsonData{
-(void)show:(const char*) jsonString{
NSString *jsonNSString = [NSString stringWithUTF8String:jsonString];
NSData *data = [jsonNSString dataUsingEncoding:NSUTF8StringEncoding];
NSMutableDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
NSLog(@" ---ios ElvaHelper--show-: %@", dict);
playerName = [dict valueForKey:@"playerName"];
playerUid = [dict valueForKey:@"playerUid"];
serverId = [dict valueForKey:@"ServerID"];

showConversationFlag = [dict valueForKey:@"PlayershowConversationFlag"];
int type = [[dict valueForKey:@"Type"] intValue];

[ECServiceSdk setUserName:playerName];
[ECServiceSdk setUserId:playerUid];

if (type == 1) {
[self showElva];
}else if (type == 2){
[self showFAQs];
}
else if (type == 3){
[self showElvaOP];
}
else if (type == 4){
[self showConversation];
}else{
[self showElva];
}

}
#pragma mark --智能客服主界面启动,调用 showElva 方法,启动机器人界面
-(void)showElva{
//您需要将相同的标签添加到“AIHELP Web控制台”才能生效。
NSMutableArray * tags = [NSMutableArray array]; //定义tag容器
[tags addObject:@"vip"];
[tags addObject:@"pay1"];

NSMutableDictionary *customData = [NSMutableDictionary dictionary];//定义自定义参数容器
[customData setObject:tags forKey:@"elva-tags"]; //添加Tag值标签
[customData setObject:@"1.0.0" forKey:@"VersionCode"]; //添加自定义的参数

NSMutableDictionary *config = [NSMutableDictionary dictionary]; //定义config参数容器
[config setObject:customData forKey:@"elva-custom-metadata"]; //将customData存入容器

[ECServiceSdk showElva:@"USER_NAME"
PlayerUid:@"USER_ID"
ServerId:@"123"
PlayerParseId:@""
PlayershowConversationFlag:@"1"
Config:config];

/* config 示例内容:
{
"elva-custom-metadata": {
"elva-tags": [
"vip",
"pay1"
],
"VersionCode": "1.0.0"
}
}
*/
}
#pragma mark --直接进行人工客服聊天,调用 showConversation 方法(必须确保设置用户名称信息 setUserName 已经调用)
-(void)showConversation{

//您需要将相同的标签添加到“AIHELP Web控制台”才能生效。
NSMutableArray * tags = [NSMutableArray array]; //定义tag容器
[tags addObject:@"vip"];
[tags addObject:@"pay1"];

NSMutableDictionary *customData = [NSMutableDictionary dictionary];//定义自定义参数容器
[customData setObject:tags forKey:@"elva-tags"]; //添加Tag值标签
[customData setObject:@"1.0.0" forKey:@"VersionCode"]; //添加自定义的参数

NSMutableDictionary *config = [NSMutableDictionary dictionary]; //定义config参数容器
[config setObject:customData forKey:@"elva-custom-metadata"]; //将customData存入容器

[ECServiceSdk showConversation:@"PLAYER_ID" ServerId:@"123" Config:config];
[ECServiceSdk showElva:playerName
PlayerUid:playerUid
ServerId:serverId
PlayerParseId:playerParseId
PlayershowConversationFlag:showConversationFlag];
}

#pragma mark --展示FAQ列表,调用 showFAQs 方法(必须确保设置用户名称信息 setUserName 和设置用户唯一id信息 setUserId 已经调用)
-(void)showFAQs{


//您需要将相同的标签添加到“AIHELP Web控制台”才能生效。
// NSMutableArray * tags = [NSMutableArray array]; //定义tag容器
// [tags addObject:@"vip"];
// [tags addObject:@"pay1"];
NSMutableDictionary *customData = [NSMutableDictionary dictionary];//定义自定义参数容器
// [customData setObject:tags forKey:@"elva-tags"]; //添加Tag值标签
[customData setObject:@"自定义的参数123456" forKey:@"自定义的参数"]; //添加自定义的参数

[customData setObject:@"自定义人工欢迎语" forKey:@"private_welcome_str"]; //添加自定义人工欢迎语
[customData setObject:@"自定义欢迎语" forKey:@"anotherWelcomeText"]; //添加自定义欢迎语

NSMutableDictionary *config = [NSMutableDictionary dictionary]; //定义config参数容器
[config setObject:@"1" forKey:@"showContactButtonFlag"];
[config setObject:@"1" forKey:@"showConversationFlag"];
[config setObject:customData forKey:@"elva-custom-metadata"]; //将customData存入容器
//一、联系我们按钮显示逻辑
// 0、默认:FAQ列表页和详情页不显示,点击“踩”,显示联系我们按钮。不用处理 config。
// 1、一直显示:需要设置'showContactButtonFlag',添加如下代码即可
// [config setObject:@"1" forKey:@"showContactButtonFlag"];
// 2、永不显示:需要设置'hideContactButtonFlag',添加如下代码即可
// [config setObject:@"1" forKey:@"hideContactButtonFlag"];

//二、点击联系我们按钮(经过一步骤,显示了联系我们按钮的前提)进入客服页面的逻辑
// 0、默认:进入机器人页面(无进行中客诉时,不显示人工客服按钮)。不用处理 config。
// 1、直接进入人工页面:需要设置'directConversation',添加如下代码即可
// [config setObject:@"1" forKey:@"directConversation"];
// 2、进入机器人页面+人工客服入口按钮:需要设置'showConversationFlag',添加如下代码即可
// [config setObject:@"1" forKey:@"showConversationFlag"];

[ECServiceSdk showFAQs:config];
//[ECServiceSdk showFAQSection:@"158455" Config:config];//展示相关部分FAQ SectionID需要后台配置
}
#pragma mark --运营主界面启动
-(void)showElvaOP{
//您需要将相同的标签添加到“AIHELP Web控制台”才能生效。
NSMutableArray * tags = [NSMutableArray array]; //定义tag容器
[tags addObject:@"vip"];
[tags addObject:@"pay1"];

NSMutableDictionary *customData = [NSMutableDictionary dictionary];//定义自定义参数容器
[customData setObject:tags forKey:@"elva-tags"]; //添加Tag值标签
[customData setObject:@"1.0.0" forKey:@"VersionCode"]; //添加自定义的参数

NSMutableDictionary *config = [NSMutableDictionary dictionary]; //定义config参数容器
[config setObject:customData forKey:@"elva-custom-metadata"]; //将customData存入容器

[ECServiceSdk showElvaOP:@"USER_NAME"
PlayerUid:@"USER_ID"
ServerId:@"123"
PlayerParseId:@""
PlayershowConversationFlag:@"1"
Config:config];
[ECServiceSdk showElvaOP:playerName
PlayerUid:playerUid
ServerId:serverId
PlayerParseId:playerParseId
PlayershowConversationFlag:showConversationFlag
Config:nil];
}
#pragma mark --直接进行人工客服聊天,调用 showConversation 方法(必须确保设置用户名称信息 setUserName 已经调用)
-(void)showConversation{
[ECServiceSdk showConversation:playerUid ServerId:serverId];
}
@end
8 changes: 2 additions & 6 deletions TestProject/Assets/Plugins/IOS/FBHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@
-(void)InitSDK:(id<cDelegate>)Delegate;
-(void)Login;
-(void)Logout;
-(void)share:(const char*) jsonData;
-(void)FBShareUrl;
-(void)FBShareImage;
-(void)Event:(const char*) jsonData;
-(void)share:(const char*) jsonString;
-(void)Event:(const char*) jsonString;
-(void)CustomEvent:(NSString *)eventName;
-(void)AchieveLevelEvent:(NSString *)level;
-(void)CompleteTutorialEvent:(NSString *)contentData contentId:(NSString *)contentId success:(BOOL)success;
-(void)purchaseEvent:(NSString *)appleOrderID AndProductID:(NSString *)productID;
@end
34 changes: 23 additions & 11 deletions TestProject/Assets/Plugins/IOS/FBHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ +(FBHelper*)sharedInstance{

-(void)InitSDK:(id<cDelegate>)delegate{
IOSBridgeHelper = delegate;
[FBSDKSettings setAppID:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"FacebookAppID"]];

RVC = [[[UIApplication sharedApplication] delegate] window].rootViewController;

[FBSDKSettings setAppID:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"FacebookAppID"]];
[FBSDKSettings setAutoLogAppEventsEnabled:YES];
[FBSDKSettings setAutoInitEnabled: YES ];

[FBSDKSettings setAdvertiserIDCollectionEnabled:@YES];
NSLog(@"---FBHelper---InitSDK---");
}
Expand Down Expand Up @@ -218,27 +217,40 @@ -(void)sharerDidCancel:(id<FBSDKSharing>)sharer {
//******************************************************
//****************FaceBook Event
//******************************************************
-(void)Event:(const char*) jsonData{

-(void)Event:(const char*) jsonString{
NSString *jsonNSString = [NSString stringWithUTF8String:jsonString];
NSData *data = [jsonNSString dataUsingEncoding:NSUTF8StringEncoding];
NSMutableDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
NSLog(@" ---ios FBHelper--Event-: %@", dict);
int type = [[dict valueForKey:@"Type"] intValue];
NSString *level = [dict valueForKey:@"level"];
NSString *contentData = [dict valueForKey:@"contentData"];
NSString *contentId = [dict valueForKey:@"contentId"];
NSString *success = [dict valueForKey:@"success"];
if(type == 1){
[self AchieveLevelEvent:level];//-->玩家通过关卡“1-13”后,触发该事件
}else if(type == 2){
[self CompleteTutorialEvent:contentData contentId:contentId success:success]; //-->玩家通过关卡“1-2”后,触发该事件
}
}
-(void)CustomEvent:(NSString *)eventName{
[FBSDKAppEvents logEvent:eventName];
}
#pragma mark --完成关卡-->玩家通过关卡“1-13”后,触发该事件
#pragma mark --完成关卡
-(void)AchieveLevelEvent:(NSString *)level{
NSDictionary *params =
@{FBSDKAppEventParameterNameLevel : level};
[FBSDKAppEvents
logEvent:FBSDKAppEventNameAchievedLevel
parameters:params];
}
#pragma mark --完成教程学习-->玩家通过关卡“1-2”后,触发该事件
-(void)CompleteTutorialEvent:(NSString *)contentData contentId:(NSString *)contentId success:(BOOL)success{
#pragma mark --完成教程学习
-(void)CompleteTutorialEvent:(NSString *)contentData contentId:(NSString *)contentId success:(NSString *)success{
NSDictionary *params =
@{
FBSDKAppEventParameterNameContent : contentData,
FBSDKAppEventParameterNameContentID : contentId,
FBSDKAppEventParameterNameSuccess : @(success ? 1 : 0)
FBSDKAppEventParameterNameSuccess : success //“1”或“0”
};
[FBSDKAppEvents
logEvent:FBSDKAppEventNameCompletedTutorial
Expand All @@ -255,8 +267,8 @@ -(void)purchaseEvent:(NSString *)appleOrderID AndProductID:(NSString *)productID
NSDictionary *params =
@{
FBSDKAppEventParameterNameContentType : productID,
FBSDKAppEventParameterNameOrderID : @"orderID",
FBSDKAppEventParameterNameCurrency : appleOrderID
FBSDKAppEventParameterNameOrderID : appleOrderID,
FBSDKAppEventParameterNameCurrency : currency
};
[FBSDKAppEvents logPurchase:priceDouble
currency:currency
Expand Down
Loading

0 comments on commit 82d81c0

Please sign in to comment.