现在 需要接入ios友盟统计sdk,我查看了友盟官方的文档和教程试了好几遍有出入,不一样
有大神接入过能分享一下流程吗 急急
大佬在哪里~
顶别沉了
没有人接过吗,无助啊
/**
* 计数统计
*/
init(debug:boolean,period:number = 60,channel:string = ‘’):void {
if(!cc.sys.isNative){
return;
}
if(cc.sys.os == cc.sys.OS_ANDROID){
var location = jsb.reflection.callStaticMethod(this._android, "init", "(ZILjava/lang/String;)V",debug,period,channel);
return location;
}
if(cc.sys.os == cc.sys.OS_IOS){
var location = jsb.reflection.callStaticMethod(this._ios, "init:period:channel:",debug,period,channel);
return location;
}
}
/**
* 计数统计
*/
count(eventName:string,params:Object = null):void {
if(!cc.sys.isNative){
return;
}
var str = null;
if(params != null){
str = JSON.stringify(params);
}
if(cc.sys.os == cc.sys.OS_ANDROID){
var location = jsb.reflection.callStaticMethod(this._android, "count", "(Ljava/lang/String;Ljava/lang/String;)V",eventName,str);
return location;
}
if(cc.sys.os == cc.sys.OS_IOS){
var location = jsb.reflection.callStaticMethod(this._ios, "count:params:",eventName,str);
return location;
}
}
其它依照自己写就可以了
#import “Analy.h”
#import “Native.h”
// 引入JAnalytics功能所需头文件
#import “JANALYTICSService.h”
@implementation Analy
//初始化
-
(void)init:(bool)debug period:(int)period channel:(NSString *)channel{
JANALYTICSLaunchConfig * config = [[JANALYTICSLaunchConfig alloc] init];
config.appKey = @“0d3764f18919f9596c10a000”;
config.channel = channel;
[JANALYTICSService setDebug:debug];
[JANALYTICSService setupWithConfig:config];
[JANALYTICSService setFrequency:period];
}
//计数统计
-
(void)count:(NSString )eventName params:(NSString)params {
JANALYTICSCountEvent * event = [[JANALYTICSCountEvent alloc] init];
event.eventID = eventName;if(params != nil){
NSData *jsonData = [params dataUsingEncoding:NSUTF8StringEncoding];
NSError *err = nil;
NSDictionary *eventParams = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err];if(err == nil && [[eventParams allKeys] count] > 0){ event.extra = eventParams; }}
[JANALYTICSService eventRecord:event];
}
/**
* 初始化
* @param debug
* @param period
*/
public static void init(boolean debug,int period,String channel){
JAnalyticsInterface.setDebugMode(debug);
JAnalyticsInterface.init(Native.getActivity());
JAnalyticsInterface.setAnalyticsReportPeriod(Native.getActivity(), period);
JAnalyticsInterface.setChannel(Native.getActivity(), channel);
}
/**
* 计数事件
*/
public static void count(String eventName,String jsonStr){
try {
CountEvent cEvent = new CountEvent(eventName);
if(jsonStr == null){
HashMap<String, String> hashMap=JSON.parseObject(jsonStr, HashMap.class);
cEvent.setExtMap(hashMap);
}
JAnalyticsInterface.onEvent(Native.getActivity(), cEvent);
} catch (Exception e) {
e.printStackTrace();
}
}
谢谢啊哈哈哈哈哈
解决了
感谢大佬