mirror of
https://github.com/camelwoo/umeng-analytics-cordova-plugin.git
synced 2026-01-27 00:00:06 +08:00
init
This commit is contained in:
@@ -1,2 +1,11 @@
|
||||
# umeng-analytics-cordova-plugin
|
||||
友盟统计的 cordova 插件
|
||||
|
||||
**github 上已经有一些插件,也能实现相应的功能。实现这个插件是为了熟悉一下 cordova 插件的制作。**
|
||||
|
||||
**工作环境中慎用**
|
||||
|
||||
其它说明:
|
||||
|
||||
* 参考了 [Ql_Umeng](https://github.com/Bjkb/Ql_Umeng) 插件。
|
||||
* 使用了基本上是最新的友盟SDK。
|
||||
19
package.json
Normal file
19
package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "umeng-analytics-cordova-plugin",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"cordova": {
|
||||
"id": "umeng-analytics-cordova-plugin",
|
||||
"platforms": [
|
||||
"android",
|
||||
"ios"
|
||||
]
|
||||
},
|
||||
"keywords": [
|
||||
"ecosystem:cordova",
|
||||
"cordova-android",
|
||||
"cordova-ios"
|
||||
],
|
||||
"author": "wux",
|
||||
"license": "MIT"
|
||||
}
|
||||
67
plugin.xml
Normal file
67
plugin.xml
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<plugin id="umeng-analytics-cordova-plugin" version="1.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<name>Umeng Analytics Plugin</name>
|
||||
<description>Umeng Analytics Plugin</description>
|
||||
<license>MIT</license>
|
||||
<keywords>umeng</keywords>
|
||||
<repo>https://github.com/camelwoo/umeng-analytics-cordova-plugin.git</repo>
|
||||
<issue>https://github.com/camelwoo/umeng-analytics-cordova-plugin/issues</issue>
|
||||
|
||||
<preference name="APP_KEY" />
|
||||
|
||||
<js-module name="umeng-analytics-cordova-plugin" src="www/analyticssdk.js">
|
||||
<clobbers target="UmAnalytics" />
|
||||
</js-module>
|
||||
<platform name="android">
|
||||
<config-file parent="/*" target="res/xml/config.xml">
|
||||
<feature name="AnalyticsSDK">
|
||||
<param name="android-package" value="com.umeng.plugin.AnalyticsSDK" />
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<preference name="CHANNEL" />
|
||||
|
||||
<source-file src="src/android/com/umeng/plugin/PGCommonSDK.java" target-dir="src/com/umeng/plugin/" />
|
||||
<source-file src="src/android/com/umeng/plugin/AnalyticsSDK.java" target-dir="src/com/umeng/plugin/" />
|
||||
<source-file src="src/android/umeng-common-1.4.1.jar" target-dir="libs" />
|
||||
<source-file src="src/android/umeng-analytics-7.4.1.jar" target-dir="libs" />
|
||||
|
||||
<config-file target="AndroidManifest.xml" parent="application">
|
||||
<!-- appkey -->
|
||||
<meta-data android:name="UMENG_APPKEY" android:value="$APP_KEY" />
|
||||
<meta-data android:name="UMENG_CHANNEL" android:value="$CHANNEL"/>
|
||||
</config-file>
|
||||
<config-file target="AndroidManifest.xml" parent="/manifest">
|
||||
<!-- 必须的权限 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- 推荐的权限 -->
|
||||
<!-- 添加如下权限,以便使用更多的第三方SDK和更精准的统计数据 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
</config-file>
|
||||
</platform>
|
||||
<platform name="ios">
|
||||
<config-file parent="/*" target="config.xml">
|
||||
<feature name="AnalyticsSDK">
|
||||
<param name="ios-package" value="UMAnalyticsModule" />
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/ios/UMAnalytics.framework" framework="true" />
|
||||
<source-file src="src/ios/UMCommon.framework" framework="true" />
|
||||
|
||||
<header-file src="src/ios/UMCommonModule.h" />
|
||||
<source-file src="src/ios/UMCommonModule.m" />
|
||||
<header-file src="src/ios/UMAnalyticsModule.h" />
|
||||
<source-file src="src/ios/UMAnalyticsModule.m" />
|
||||
|
||||
<framework src="CoreTelephony.framework" />
|
||||
<framework src="libsqlite3.tbd"/>
|
||||
<framework src="libz.tbd"/>
|
||||
</platform>
|
||||
</plugin>
|
||||
302
src/android/com/umeng/plugin/AnalyticsSDK.java
Normal file
302
src/android/com/umeng/plugin/AnalyticsSDK.java
Normal file
@@ -0,0 +1,302 @@
|
||||
package com.umeng.plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
import com.umeng.analytics.MobclickAgent.EScenarioType;
|
||||
import com.umeng.analytics.dplus.UMADplus;
|
||||
import com.umeng.analytics.game.UMGameAgent;
|
||||
import com.umeng.commonsdk.UMConfigure;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaInterface;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Created by wangfei on 17/9/26.
|
||||
*/
|
||||
|
||||
public class AnalyticsSDK extends CordovaPlugin {
|
||||
private Context mContext = null;
|
||||
/**
|
||||
* 可以设置是否为游戏,如果是游戏会进行初始化
|
||||
*/
|
||||
private boolean isGameInited = false;
|
||||
|
||||
/**
|
||||
* 初始化游戏
|
||||
*/
|
||||
private void initGame() {
|
||||
UMGameAgent.init(mContext);
|
||||
UMGameAgent.setPlayerLevel(1);
|
||||
MobclickAgent.setScenarioType(mContext, EScenarioType.E_UM_GAME);
|
||||
isGameInited = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
||||
super.initialize(cordova, webView);
|
||||
this.mContext = cordova.getActivity().getApplicationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(boolean multitasking) {
|
||||
super.onResume(multitasking);
|
||||
Log.d("UMPlugin", "onResume");
|
||||
MobclickAgent.onResume(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause(boolean multitasking) {
|
||||
super.onPause(multitasking);
|
||||
Log.d("UMPlugin", "onPause");
|
||||
MobclickAgent.onPause(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||
Log.d("UMPlugin", "execute action:" + action + "|||args:" + args);
|
||||
if (action.equals("init")) { // added
|
||||
String appKey = args.getString(0);
|
||||
String channelId = args.getString(1);
|
||||
PGCommonSDK.init(mContext, appKey, channelId, UMConfigure.DEVICE_TYPE_PHONE, null);
|
||||
MobclickAgent.setScenarioType(mContext, EScenarioType.E_UM_NORMAL);
|
||||
MobclickAgent.onResume(mContext);
|
||||
return true;
|
||||
} else if (action.equals("onEvent")) {
|
||||
String eventId = args.getString(0);
|
||||
MobclickAgent.onEvent(mContext, eventId);
|
||||
return true;
|
||||
} else if (action.equals("onEventWithLabel")) {
|
||||
String eventId = args.getString(0);
|
||||
String label = args.getString(1);
|
||||
MobclickAgent.onEvent(mContext, eventId, label);
|
||||
return true;
|
||||
} else if (action.equals("onEventWithParameters")) {
|
||||
String eventId = args.getString(0);
|
||||
JSONObject obj = args.getJSONObject(1);
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Iterator<String> it = obj.keys();
|
||||
while (it.hasNext()) {
|
||||
String key = String.valueOf(it.next());
|
||||
Object o = obj.get(key);
|
||||
if (o instanceof Integer) {
|
||||
String value = String.valueOf(o);
|
||||
map.put(key, value);
|
||||
} else if (o instanceof String) {
|
||||
String strValue = (String) o;
|
||||
map.put(key, strValue);
|
||||
}
|
||||
}
|
||||
MobclickAgent.onEvent(mContext, eventId, map);
|
||||
return true;
|
||||
} else if (action.equals("onEventWithCounter")) {
|
||||
String eventId = args.getString(0);
|
||||
JSONObject obj = args.getJSONObject(1);
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Iterator<String> it = obj.keys();
|
||||
while (it.hasNext()) {
|
||||
String key = String.valueOf(it.next());
|
||||
Object o = obj.get(key);
|
||||
if (o instanceof Integer) {
|
||||
String value = String.valueOf(o);
|
||||
map.put(key, value);
|
||||
} else if (o instanceof String) {
|
||||
String strValue = (String) o;
|
||||
map.put(key, strValue);
|
||||
}
|
||||
}
|
||||
int value = args.getInt(2);
|
||||
MobclickAgent.onEventValue(mContext, eventId, map, value);
|
||||
return true;
|
||||
} else if (action.equals("onPageBegin")) {
|
||||
String pageName = args.getString(0);
|
||||
MobclickAgent.onPageStart(pageName);
|
||||
return true;
|
||||
} else if (action.equals("onPageEnd")) {
|
||||
String pageName = args.getString(0);
|
||||
MobclickAgent.onPageEnd(pageName);
|
||||
return true;
|
||||
} else if (action.equals("getDeviceId")) {
|
||||
try {
|
||||
android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) mContext
|
||||
.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
String deviceId = tm.getDeviceId();
|
||||
callbackContext.success(deviceId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
} else if (action.equals("setLogEnabled")) {
|
||||
boolean enabled = args.getBoolean(0);
|
||||
MobclickAgent.setDebugMode(enabled);
|
||||
return true;
|
||||
} else if (action.equals("profileSignInWithPUID")) {
|
||||
String puid = args.getString(0);
|
||||
MobclickAgent.onProfileSignIn(puid);
|
||||
return true;
|
||||
} else if (action.equals("profileSignInWithPUIDWithProvider")) {
|
||||
String puid = args.getString(0);
|
||||
String provider = args.getString(1);
|
||||
MobclickAgent.onProfileSignIn(puid, provider);
|
||||
return true;
|
||||
} else if (action.equals("profileSignOff")) {
|
||||
MobclickAgent.onProfileSignOff();
|
||||
return true;
|
||||
} else if (action.equals("setUserLevelId")) {
|
||||
if (!isGameInited) {
|
||||
initGame();
|
||||
}
|
||||
int level = args.getInt(0);
|
||||
UMGameAgent.setPlayerLevel(level);
|
||||
return true;
|
||||
} else if (action.equals("startLevel")) {
|
||||
if (!isGameInited) {
|
||||
initGame();
|
||||
}
|
||||
String level = args.getString(0);
|
||||
UMGameAgent.startLevel(level);
|
||||
return true;
|
||||
} else if (action.equals("finishLevel")) {
|
||||
if (!isGameInited) {
|
||||
initGame();
|
||||
}
|
||||
String level = args.getString(0);
|
||||
UMGameAgent.failLevel(level);
|
||||
return true;
|
||||
} else if (action.equals("failLevel")) {
|
||||
if (!isGameInited) {
|
||||
initGame();
|
||||
}
|
||||
String level = args.getString(0);
|
||||
UMGameAgent.finishLevel(level);
|
||||
|
||||
return true;
|
||||
} else if (action.equals("exchange")) {
|
||||
if (!isGameInited) {
|
||||
initGame();
|
||||
}
|
||||
double currencyAmount = args.getDouble(0);
|
||||
String currencyType = args.getString(1);
|
||||
double virtualAmount = args.getDouble(2);
|
||||
int channel = args.getInt(3);
|
||||
String orderId = args.getString(4);
|
||||
UMGameAgent.exchange(currencyAmount, currencyType, virtualAmount, channel, orderId);
|
||||
return true;
|
||||
} else if (action.equals("pay")) {
|
||||
if (!isGameInited) {
|
||||
initGame();
|
||||
}
|
||||
double money = args.getDouble(0);
|
||||
double coin = args.getDouble(1);
|
||||
int source = args.getInt(2);
|
||||
UMGameAgent.pay(money, coin, source);
|
||||
return true;
|
||||
} else if (action.equals("payWithItem")) {
|
||||
if (!isGameInited) {
|
||||
initGame();
|
||||
}
|
||||
double money = args.getDouble(0);
|
||||
String item = args.getString(1);
|
||||
int number = args.getInt(2);
|
||||
double price = args.getDouble(3);
|
||||
int source = args.getInt(4);
|
||||
UMGameAgent.pay(money, item, number, price, source);
|
||||
return true;
|
||||
} else if (action.equals("buy")) {
|
||||
if (!isGameInited) {
|
||||
initGame();
|
||||
}
|
||||
String item = args.getString(0);
|
||||
int number = args.getInt(1);
|
||||
double price = args.getDouble(2);
|
||||
UMGameAgent.buy(item, number, price);
|
||||
return true;
|
||||
} else if (action.equals("use")) {
|
||||
if (!isGameInited) {
|
||||
initGame();
|
||||
}
|
||||
String item = args.getString(0);
|
||||
int number = args.getInt(1);
|
||||
double price = args.getDouble(2);
|
||||
UMGameAgent.use(item, number, price);
|
||||
return true;
|
||||
} else if (action.equals("bonus")) {
|
||||
if (!isGameInited) {
|
||||
initGame();
|
||||
}
|
||||
double coin = args.getDouble(0);
|
||||
int source = args.getInt(1);
|
||||
UMGameAgent.bonus(coin, source);
|
||||
return true;
|
||||
} else if (action.equals("bonusWithItem")) {
|
||||
if (!isGameInited) {
|
||||
initGame();
|
||||
}
|
||||
String item = args.getString(0);
|
||||
int number = args.getInt(1);
|
||||
double price = args.getDouble(2);
|
||||
int source = args.getInt(3);
|
||||
UMGameAgent.bonus(item, number, price, source);
|
||||
return true;
|
||||
} else if (action.equals("track")) {
|
||||
String eventName = args.getString(0);
|
||||
Log.d("UMPlugin", "track="+eventName);
|
||||
UMADplus.track(mContext, eventName);
|
||||
return true;
|
||||
} else if (action.equals("trackWithProperty")) {
|
||||
String eventName = args.getString(0);
|
||||
JSONObject obj = args.getJSONObject(1);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Iterator<String> it = obj.keys();
|
||||
while (it.hasNext()) {
|
||||
String key = String.valueOf(it.next());
|
||||
Object o = obj.get(key);
|
||||
map.put(key, o);
|
||||
}
|
||||
UMADplus.track(mContext, eventName, map);
|
||||
return true;
|
||||
} else if (action.equals("registerSuperProperty")) {
|
||||
String propertyKey = args.getString(0);
|
||||
String propertyValue = args.getString(1);
|
||||
UMADplus.registerSuperProperty(mContext, propertyKey, propertyValue);
|
||||
return true;
|
||||
} else if (action.equals("unregisterSuperProperty")) {
|
||||
String propertyName = args.getString(0);
|
||||
UMADplus.unregisterSuperProperty(mContext, propertyName);
|
||||
return true;
|
||||
} else if (action.equals("getSuperProperty")) {
|
||||
String propertyName = args.getString(0);
|
||||
String res = (String) UMADplus.getSuperProperty(mContext, propertyName);
|
||||
callbackContext.success(res);
|
||||
return true;
|
||||
} else if (action.equals("getSuperProperties")) {
|
||||
String res = UMADplus.getSuperProperties(mContext);
|
||||
callbackContext.success(res);
|
||||
return true;
|
||||
} else if (action.equals("clearSuperProperties")) {
|
||||
UMADplus.clearSuperProperties(mContext);
|
||||
return true;
|
||||
} else if (action.equals("setFirstLaunchEvent")) {
|
||||
JSONArray array = args.getJSONArray(0);
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
list.add(array.getString(i));
|
||||
}
|
||||
UMADplus.setFirstLaunchEvent(mContext, list);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
42
src/android/com/umeng/plugin/PGCommonSDK.java
Normal file
42
src/android/com/umeng/plugin/PGCommonSDK.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.umeng.plugin;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import com.umeng.commonsdk.UMConfigure;
|
||||
|
||||
/**
|
||||
* Created by wangfei on 17/9/28.
|
||||
*/
|
||||
|
||||
public class PGCommonSDK {
|
||||
public static void init(Context context, String appkey, String channel, int type, String secret){
|
||||
initCocos("phonegap","1.0");
|
||||
UMConfigure.init(context,appkey,channel,type,secret);
|
||||
}
|
||||
public static void initCocos(String v,String t){
|
||||
|
||||
Method method = null;
|
||||
try {
|
||||
|
||||
Class<?> config = Class.forName("com.umeng.commonsdk.UMConfigure");
|
||||
method = config.getDeclaredMethod("setWraperType", String.class, String.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(null, v,t);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static void setLogEnabled(boolean able){
|
||||
|
||||
UMConfigure.setLogEnabled(able);
|
||||
}
|
||||
}
|
||||
6
src/android/umeng-analytics.gradle
Normal file
6
src/android/umeng-analytics.gradle
Normal file
@@ -0,0 +1,6 @@
|
||||
repositories{
|
||||
mavenCentral()
|
||||
flatDir{
|
||||
dirs 'libs'
|
||||
}
|
||||
}
|
||||
1
src/ios/UMAnalytics.framework/5.4.1_867507e2af_20171220112928
Executable file
1
src/ios/UMAnalytics.framework/5.4.1_867507e2af_20171220112928
Executable file
@@ -0,0 +1 @@
|
||||
5.4.1
|
||||
1
src/ios/UMAnalytics.framework/Headers
Symbolic link
1
src/ios/UMAnalytics.framework/Headers
Symbolic link
@@ -0,0 +1 @@
|
||||
Versions/Current/Headers
|
||||
1
src/ios/UMAnalytics.framework/UMAnalytics
Symbolic link
1
src/ios/UMAnalytics.framework/UMAnalytics
Symbolic link
@@ -0,0 +1 @@
|
||||
Versions/Current/UMAnalytics
|
||||
77
src/ios/UMAnalytics.framework/Versions/A/Headers/DplusMobClick.h
Executable file
77
src/ios/UMAnalytics.framework/Versions/A/Headers/DplusMobClick.h
Executable file
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// DplusMobClick.h
|
||||
// Analytics
|
||||
//
|
||||
// Copyright (C) 2010-2016 Umeng.com . All rights reserved.
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface DplusMobClick : NSObject
|
||||
|
||||
/** Dplus增加事件
|
||||
@param eventName 事件名
|
||||
@param property 自定义属性
|
||||
*/
|
||||
+(void) track:(NSString *)eventName;
|
||||
+(void) track:(NSString *)eventName property:(NSDictionary *) property;
|
||||
|
||||
/**
|
||||
* 设置属性 键值对 会覆盖同名的key
|
||||
* 将该函数指定的key-value写入dplus专用文件;APP启动时会自动读取该文件的所有key-value,并将key-value自动作为后续所有track事件的属性。
|
||||
*/
|
||||
+(void) registerSuperProperty:(NSDictionary *)property;
|
||||
|
||||
/**
|
||||
*
|
||||
* 从dplus专用文件中删除指定key-value
|
||||
@param key
|
||||
*/
|
||||
+(void) unregisterSuperProperty:(NSString *)propertyName;
|
||||
|
||||
/**
|
||||
*
|
||||
* 返回dplus专用文件中key对应的value;如果不存在,则返回空。
|
||||
@param key
|
||||
@return void
|
||||
*/
|
||||
+(NSString *)getSuperProperty:(NSString *)propertyName;
|
||||
|
||||
/**
|
||||
* 返回Dplus专用文件中的所有key-value;如果不存在,则返回空。
|
||||
*/
|
||||
+(NSDictionary *)getSuperProperties;
|
||||
|
||||
/**
|
||||
*清空Dplus专用文件中的所有key-value。
|
||||
*/
|
||||
+(void)clearSuperProperties;
|
||||
|
||||
/**
|
||||
* 设置预置事件属性 键值对 会覆盖同名的key
|
||||
*/
|
||||
+(void) registerPreProperties:(NSDictionary *)property;
|
||||
|
||||
/**
|
||||
*
|
||||
* 删除指定预置事件属性
|
||||
@param key
|
||||
*/
|
||||
+(void) unregisterPreProperty:(NSString *)propertyName;
|
||||
|
||||
/**
|
||||
* 获取预置事件所有属性;如果不存在,则返回空。
|
||||
*/
|
||||
+(NSDictionary *)getPreProperties;
|
||||
|
||||
/**
|
||||
*清空所有预置事件属性。
|
||||
*/
|
||||
+(void)clearPreProperties;
|
||||
|
||||
|
||||
/**
|
||||
* 设置关注事件是否首次触发,只关注eventList前五个合法eventID.只要已经保存五个,此接口无效
|
||||
*/
|
||||
+(void)setFirstLaunchEvent:(NSArray *)eventList;
|
||||
@end
|
||||
214
src/ios/UMAnalytics.framework/Versions/A/Headers/MobClick.h
Executable file
214
src/ios/UMAnalytics.framework/Versions/A/Headers/MobClick.h
Executable file
@@ -0,0 +1,214 @@
|
||||
//
|
||||
// MobClick.h
|
||||
// Analytics
|
||||
//
|
||||
// Copyright (C) 2010-2017 Umeng.com . All rights reserved.
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
typedef void(^CallbackBlock)();
|
||||
|
||||
/**
|
||||
统计的场景类别,默认为普通统计;若使用游戏统计API,则需选择游戏场景类别,如E_UM_GAME。
|
||||
*/
|
||||
typedef NS_ENUM (NSUInteger, eScenarioType)
|
||||
{
|
||||
E_UM_NORMAL = 0, // default value
|
||||
E_UM_GAME = 1, // game
|
||||
E_UM_DPLUS = 4 // DPlus
|
||||
};
|
||||
|
||||
@class CLLocation;
|
||||
@interface MobClick : NSObject <UIAlertViewDelegate>
|
||||
|
||||
#pragma mark basics
|
||||
|
||||
///---------------------------------------------------------------------------------------
|
||||
/// @name 设置
|
||||
///---------------------------------------------------------------------------------------
|
||||
|
||||
/** 设置 统计场景类型,默认为普通应用统计:E_UM_NORMAL
|
||||
@param 游戏统计必须设置为:E_UM_GAME.
|
||||
@return void.
|
||||
*/
|
||||
+ (void)setScenarioType:(eScenarioType)eSType;
|
||||
|
||||
/** 开启CrashReport收集, 默认YES(开启状态).
|
||||
@param value 设置为NO,可关闭友盟CrashReport收集功能.
|
||||
@return void.
|
||||
*/
|
||||
+ (void)setCrashReportEnabled:(BOOL)value;
|
||||
|
||||
#pragma mark event logs
|
||||
///---------------------------------------------------------------------------------------
|
||||
/// @name 页面计时
|
||||
///---------------------------------------------------------------------------------------
|
||||
|
||||
/** 手动页面时长统计, 记录某个页面展示的时长.
|
||||
@param pageName 统计的页面名称.
|
||||
@param seconds 单位为秒,int型.
|
||||
@return void.
|
||||
*/
|
||||
+ (void)logPageView:(NSString *)pageName seconds:(int)seconds;
|
||||
|
||||
/** 自动页面时长统计, 开始记录某个页面展示时长.
|
||||
使用方法:必须配对调用beginLogPageView:和endLogPageView:两个函数来完成自动统计,若只调用某一个函数不会生成有效数据。
|
||||
在该页面展示时调用beginLogPageView:,当退出该页面时调用endLogPageView:
|
||||
@param pageName 统计的页面名称.
|
||||
@return void.
|
||||
*/
|
||||
+ (void)beginLogPageView:(NSString *)pageName;
|
||||
|
||||
/** 自动页面时长统计, 结束记录某个页面展示时长.
|
||||
使用方法:必须配对调用beginLogPageView:和endLogPageView:两个函数来完成自动统计,若只调用某一个函数不会生成有效数据。
|
||||
在该页面展示时调用beginLogPageView:,当退出该页面时调用endLogPageView:
|
||||
@param pageName 统计的页面名称.
|
||||
@return void.
|
||||
*/
|
||||
+ (void)endLogPageView:(NSString *)pageName;
|
||||
|
||||
|
||||
///---------------------------------------------------------------------------------------
|
||||
/// @name 事件统计
|
||||
///---------------------------------------------------------------------------------------
|
||||
|
||||
/** 自定义事件,数量统计.
|
||||
使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID
|
||||
|
||||
@param eventId 网站上注册的事件Id.
|
||||
@param label 分类标签。不同的标签会分别进行统计,方便同一事件的不同标签的对比,为nil或空字符串时后台会生成和eventId同名的标签.
|
||||
@param accumulation 累加值。为减少网络交互,可以自行对某一事件ID的某一分类标签进行累加,再传入次数作为参数。
|
||||
@return void.
|
||||
*/
|
||||
+ (void)event:(NSString *)eventId; //等同于 event:eventId label:eventId;
|
||||
/** 自定义事件,数量统计.
|
||||
使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID
|
||||
*/
|
||||
+ (void)event:(NSString *)eventId label:(NSString *)label; // label为nil或@""时,等同于 event:eventId label:eventId;
|
||||
|
||||
/** 自定义事件,数量统计.
|
||||
使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID
|
||||
*/
|
||||
+ (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes;
|
||||
|
||||
+ (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes counter:(int)number;
|
||||
|
||||
/** 自定义事件,时长统计.
|
||||
使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
|
||||
beginEvent,endEvent要配对使用,也可以自己计时后通过durations参数传递进来
|
||||
|
||||
@param eventId 网站上注册的事件Id.
|
||||
@param label 分类标签。不同的标签会分别进行统计,方便同一事件的不同标签的对比,为nil或空字符串时后台会生成和eventId同名的标签.
|
||||
@param primarykey 这个参数用于和event_id一起标示一个唯一事件,并不会被统计;对于同一个事件在beginEvent和endEvent 中要传递相同的eventId 和 primarykey
|
||||
@param millisecond 自己计时需要的话需要传毫秒进来
|
||||
@return void.
|
||||
|
||||
@warning 每个event的attributes不能超过10个
|
||||
eventId、attributes中key和value都不能使用空格和特殊字符,必须是NSString,且长度不能超过255个字符(否则将截取前255个字符)
|
||||
id, ts, du是保留字段,不能作为eventId及key的名称
|
||||
*/
|
||||
+ (void)beginEvent:(NSString *)eventId;
|
||||
|
||||
/** 自定义事件,时长统计.
|
||||
使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
|
||||
*/
|
||||
|
||||
+ (void)endEvent:(NSString *)eventId;
|
||||
/** 自定义事件,时长统计.
|
||||
使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
|
||||
*/
|
||||
|
||||
+ (void)beginEvent:(NSString *)eventId label:(NSString *)label;
|
||||
/** 自定义事件,时长统计.
|
||||
使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
|
||||
*/
|
||||
|
||||
+ (void)endEvent:(NSString *)eventId label:(NSString *)label;
|
||||
/** 自定义事件,时长统计.
|
||||
使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
|
||||
*/
|
||||
|
||||
+ (void)beginEvent:(NSString *)eventId primarykey :(NSString *)keyName attributes:(NSDictionary *)attributes;
|
||||
/** 自定义事件,时长统计.
|
||||
使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
|
||||
*/
|
||||
|
||||
+ (void)endEvent:(NSString *)eventId primarykey:(NSString *)keyName;
|
||||
/** 自定义事件,时长统计.
|
||||
使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
|
||||
*/
|
||||
|
||||
+ (void)event:(NSString *)eventId durations:(int)millisecond;
|
||||
/** 自定义事件,时长统计.
|
||||
使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
|
||||
*/
|
||||
|
||||
+ (void)event:(NSString *)eventId label:(NSString *)label durations:(int)millisecond;
|
||||
/** 自定义事件,时长统计.
|
||||
使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
|
||||
*/
|
||||
+ (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes durations:(int)millisecond;
|
||||
|
||||
|
||||
#pragma mark - user methods
|
||||
/** active user sign-in.
|
||||
使用sign-In函数后,如果结束该PUID的统计,需要调用sign-Off函数
|
||||
@param puid : user's ID
|
||||
@param provider : 不能以下划线"_"开头,使用大写字母和数字标识; 如果是上市公司,建议使用股票代码。
|
||||
@return void.
|
||||
*/
|
||||
+ (void)profileSignInWithPUID:(NSString *)puid;
|
||||
+ (void)profileSignInWithPUID:(NSString *)puid provider:(NSString *)provider;
|
||||
|
||||
/** active user sign-off.
|
||||
停止sign-in PUID的统计
|
||||
@return void.
|
||||
*/
|
||||
+ (void)profileSignOff;
|
||||
|
||||
///---------------------------------------------------------------------------------------
|
||||
/// @name 地理位置设置
|
||||
/// 需要链接 CoreLocation.framework 并且 #import <CoreLocation/CoreLocation.h>
|
||||
///---------------------------------------------------------------------------------------
|
||||
|
||||
/** 设置经纬度信息
|
||||
@param latitude 纬度.
|
||||
@param longitude 经度.
|
||||
@return void
|
||||
*/
|
||||
+ (void)setLatitude:(double)latitude longitude:(double)longitude;
|
||||
|
||||
/** 设置经纬度信息
|
||||
@param location CLLocation 经纬度信息
|
||||
@return void
|
||||
*/
|
||||
+ (void)setLocation:(CLLocation *)location;
|
||||
|
||||
///---------------------------------------------------------------------------------------
|
||||
/// @name Utility函数
|
||||
///---------------------------------------------------------------------------------------
|
||||
|
||||
/** 判断设备是否越狱,依据是否存在apt和Cydia.app
|
||||
*/
|
||||
+ (BOOL)isJailbroken;
|
||||
|
||||
/** 判断App是否被破解
|
||||
*/
|
||||
+ (BOOL)isPirated;
|
||||
|
||||
/** 设置 app secret
|
||||
@param secret string
|
||||
@return void.
|
||||
*/
|
||||
+ (void)setSecret:(NSString *)secret;
|
||||
|
||||
+ (void)setCrashCBBlock:(CallbackBlock)cbBlock;
|
||||
|
||||
/** DeepLink事件
|
||||
@param link 唤起应用的link
|
||||
@return void.
|
||||
*/
|
||||
+ (void)onDeepLinkReceived:(NSURL *)link;
|
||||
|
||||
@end
|
||||
184
src/ios/UMAnalytics.framework/Versions/A/Headers/MobClickGameAnalytics.h
Executable file
184
src/ios/UMAnalytics.framework/Versions/A/Headers/MobClickGameAnalytics.h
Executable file
@@ -0,0 +1,184 @@
|
||||
//
|
||||
// MobClickGameAnalytics.h
|
||||
// Analytics
|
||||
//
|
||||
// Copyright (C) 2010-2014 Umeng.com . All rights reserved.
|
||||
|
||||
@interface MobClickGameAnalytics : NSObject
|
||||
|
||||
#pragma mark - account function
|
||||
/** active user sign-in.
|
||||
使用sign-In函数后,如果结束该PUID的统计,需要调用sign-Off函数
|
||||
@param puid : user's ID
|
||||
@param provider : 不能以下划线"_"开头,使用大写字母和数字标识; 如果是上市公司,建议使用股票代码。
|
||||
@return void.
|
||||
*/
|
||||
+ (void)profileSignInWithPUID:(NSString *)puid;
|
||||
+ (void)profileSignInWithPUID:(NSString *)puid provider:(NSString *)provider;
|
||||
|
||||
/** active user sign-off.
|
||||
停止sign-in PUID的统计
|
||||
@return void.
|
||||
*/
|
||||
+ (void)profileSignOff;
|
||||
|
||||
#pragma mark GameLevel methods
|
||||
///---------------------------------------------------------------------------------------
|
||||
/// @name set game level
|
||||
///---------------------------------------------------------------------------------------
|
||||
|
||||
/** 设置玩家的等级.
|
||||
*/
|
||||
|
||||
/** 设置玩家等级属性.
|
||||
@param level 玩家等级
|
||||
@return void
|
||||
*/
|
||||
+ (void)setUserLevelId:(int)level;
|
||||
|
||||
///---------------------------------------------------------------------------------------
|
||||
/// @name 关卡统计
|
||||
///---------------------------------------------------------------------------------------
|
||||
|
||||
/** 记录玩家进入关卡,通过关卡及失败的情况.
|
||||
*/
|
||||
|
||||
|
||||
/** 进入关卡.
|
||||
@param level 关卡
|
||||
@return void
|
||||
*/
|
||||
+ (void)startLevel:(NSString *)level;
|
||||
|
||||
/** 通过关卡.
|
||||
@param level 关卡,如果level == nil 则为当前关卡
|
||||
@return void
|
||||
*/
|
||||
+ (void)finishLevel:(NSString *)level;
|
||||
|
||||
/** 未通过关卡.
|
||||
@param level 关卡,如果level == nil 则为当前关卡
|
||||
@return void
|
||||
*/
|
||||
|
||||
+ (void)failLevel:(NSString *)level;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Pay methods
|
||||
|
||||
///---------------------------------------------------------------------------------------
|
||||
/// @name 支付统计
|
||||
///---------------------------------------------------------------------------------------
|
||||
|
||||
/** 记录玩家交易兑换货币的情况
|
||||
@param currencyAmount 现金或等价物总额
|
||||
@param currencyType 为ISO4217定义的3位字母代码,如CNY,USD等(如使用其它自定义等价物作为现金,可使用ISO4217中未定义的3位字母组合传入货币类型)
|
||||
@param virtualAmount 虚拟币数量
|
||||
@param channel 支付渠道
|
||||
@param orderId 交易订单ID
|
||||
@return void
|
||||
*/
|
||||
+ (void)exchange:(NSString *)orderId currencyAmount:(double)currencyAmount currencyType:(NSString *)currencyType virtualCurrencyAmount:(double)virtualAmount paychannel:(int)channel;
|
||||
|
||||
/** 玩家支付货币兑换虚拟币.
|
||||
@param cash 真实货币数量
|
||||
@param source 支付渠道
|
||||
@param coin 虚拟币数量
|
||||
@return void
|
||||
*/
|
||||
|
||||
+ (void)pay:(double)cash source:(int)source coin:(double)coin;
|
||||
|
||||
/** 玩家支付货币购买道具.
|
||||
@param cash 真实货币数量
|
||||
@param source 支付渠道
|
||||
@param item 道具名称
|
||||
@param amount 道具数量
|
||||
@param price 道具单价
|
||||
@return void
|
||||
*/
|
||||
+ (void)pay:(double)cash source:(int)source item:(NSString *)item amount:(int)amount price:(double)price;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Buy methods
|
||||
|
||||
///---------------------------------------------------------------------------------------
|
||||
/// @name 虚拟币购买统计
|
||||
///---------------------------------------------------------------------------------------
|
||||
|
||||
/** 记录玩家使用虚拟币的消费情况
|
||||
*/
|
||||
|
||||
|
||||
/** 玩家使用虚拟币购买道具
|
||||
@param item 道具名称
|
||||
@param amount 道具数量
|
||||
@param price 道具单价
|
||||
@return void
|
||||
*/
|
||||
+ (void)buy:(NSString *)item amount:(int)amount price:(double)price;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Use methods
|
||||
|
||||
|
||||
///---------------------------------------------------------------------------------------
|
||||
/// @name 道具消耗统计
|
||||
///---------------------------------------------------------------------------------------
|
||||
|
||||
/** 记录玩家道具消费情况
|
||||
*/
|
||||
|
||||
|
||||
/** 玩家使用虚拟币购买道具
|
||||
@param item 道具名称
|
||||
@param amount 道具数量
|
||||
@param price 道具单价
|
||||
@return void
|
||||
*/
|
||||
|
||||
+ (void)use:(NSString *)item amount:(int)amount price:(double)price;
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Bonus methods
|
||||
|
||||
|
||||
///---------------------------------------------------------------------------------------
|
||||
/// @name 虚拟币及道具奖励统计
|
||||
///---------------------------------------------------------------------------------------
|
||||
|
||||
/** 记录玩家获赠虚拟币及道具的情况
|
||||
*/
|
||||
|
||||
|
||||
/** 玩家获虚拟币奖励
|
||||
@param coin 虚拟币数量
|
||||
@param source 奖励方式
|
||||
@return void
|
||||
*/
|
||||
|
||||
+ (void)bonus:(double)coin source:(int)source;
|
||||
|
||||
/** 玩家获道具奖励
|
||||
@param item 道具名称
|
||||
@param amount 道具数量
|
||||
@param price 道具单价
|
||||
@param source 奖励方式
|
||||
@return void
|
||||
*/
|
||||
|
||||
+ (void)bonus:(NSString *)item amount:(int)amount price:(double)price source:(int)source;
|
||||
|
||||
#pragma mark DEPRECATED
|
||||
|
||||
//已经被新的setUserLevelId:方法替代,请使用新的API。
|
||||
+ (void)setUserLevel:(NSString *)level;
|
||||
|
||||
//已经被新的active user方法替代,请使用新的API。
|
||||
+ (void)setUserID:(NSString *)userId sex:(int)sex age:(int)age platform:(NSString *)platform;
|
||||
|
||||
@end
|
||||
BIN
src/ios/UMAnalytics.framework/Versions/A/UMAnalytics
Executable file
BIN
src/ios/UMAnalytics.framework/Versions/A/UMAnalytics
Executable file
Binary file not shown.
1
src/ios/UMAnalytics.framework/Versions/Current
Symbolic link
1
src/ios/UMAnalytics.framework/Versions/Current
Symbolic link
@@ -0,0 +1 @@
|
||||
A
|
||||
49
src/ios/UMAnalyticsModule.h
Normal file
49
src/ios/UMAnalyticsModule.h
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// UMAnalyticsModule
|
||||
//
|
||||
// Created by wangkai on 16-04-14.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Cordova/CDV.h>
|
||||
|
||||
|
||||
@interface UMAnalyticsModule : CDVPlugin
|
||||
|
||||
|
||||
- (void)onEvent:(CDVInvokedUrlCommand*)command;
|
||||
- (void)onEventWithLabel:(CDVInvokedUrlCommand*)command;
|
||||
- (void)onEventWithParameters:(CDVInvokedUrlCommand*)command;
|
||||
- (void)onEventWithCounter:(CDVInvokedUrlCommand*)command;
|
||||
- (void)onPageBegin:(CDVInvokedUrlCommand*)command;
|
||||
- (void)onPageEnd:(CDVInvokedUrlCommand*)command;
|
||||
- (void)profileSignInWithPUID:(CDVInvokedUrlCommand*)command;
|
||||
- (void)profileSignInWithPUIDWithProvider:(CDVInvokedUrlCommand*)command;
|
||||
- (void)profileSignOff:(NSArray *)arguments;
|
||||
|
||||
//游戏统计
|
||||
|
||||
- (void)setUserLevelId:(CDVInvokedUrlCommand*)command;
|
||||
- (void)startLevel:(CDVInvokedUrlCommand*)command;
|
||||
- (void)finishLevel:(CDVInvokedUrlCommand*)command;
|
||||
- (void)failLevel:(CDVInvokedUrlCommand*)command;
|
||||
- (void)exchange:(CDVInvokedUrlCommand*)command;
|
||||
- (void)pay:(CDVInvokedUrlCommand*)command ;
|
||||
- (void)payWithItem:(CDVInvokedUrlCommand*)command;
|
||||
- (void)buy:(CDVInvokedUrlCommand*)command;
|
||||
- (void)use:(CDVInvokedUrlCommand*)command;
|
||||
- (void)bonus:(CDVInvokedUrlCommand*)command;
|
||||
- (void)bonusWithItem:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//Dplus
|
||||
- (void)track:(CDVInvokedUrlCommand*)command;
|
||||
- (void)trackWithProperty:(CDVInvokedUrlCommand*)command;
|
||||
- (void)registerSuperProperty:(CDVInvokedUrlCommand*)command;
|
||||
- (void)unregisterSuperProperty:(CDVInvokedUrlCommand*)command;
|
||||
- (void)getSuperProperty:(CDVInvokedUrlCommand*)command;
|
||||
- (void)getSuperProperties:(CDVInvokedUrlCommand*)command;
|
||||
- (void)clearSuperProperties:(CDVInvokedUrlCommand*)commands;
|
||||
- (void)setFirstLaunchEvent:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@end
|
||||
384
src/ios/UMAnalyticsModule.m
Executable file
384
src/ios/UMAnalyticsModule.m
Executable file
@@ -0,0 +1,384 @@
|
||||
//
|
||||
// UMAnalyticsModule
|
||||
//
|
||||
// Created by wangkai on 16-04-14.
|
||||
//
|
||||
//
|
||||
|
||||
#import "UMAnalyticsModule.h"
|
||||
#import <UMAnalytics/MobClick.h>
|
||||
#import <UMAnalytics/MobClickGameAnalytics.h>
|
||||
#import <UMAnalytics/DplusMobClick.h>
|
||||
|
||||
|
||||
@interface UMAnalyticsModule ()
|
||||
|
||||
#if __has_feature(objc_arc)
|
||||
@property (nonatomic, strong) NSString *currPageName;
|
||||
#else
|
||||
@property (nonatomic, retain) NSString *currPageName;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
@implementation UMAnalyticsModule
|
||||
|
||||
#if __has_feature(objc_arc)
|
||||
#else
|
||||
- (void)dealloc {
|
||||
[super dealloc];
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
- (void)onEvent:(CDVInvokedUrlCommand*)command {
|
||||
NSString *eventId = [command.arguments objectAtIndex:0];
|
||||
if (eventId == nil || [eventId isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
[MobClick event:eventId];
|
||||
}
|
||||
|
||||
- (void)onEventWithLabel:(CDVInvokedUrlCommand*)command{
|
||||
NSString *eventId = [command.arguments objectAtIndex:0];
|
||||
if (eventId == nil || [eventId isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
NSString *eventLabel = [command.arguments objectAtIndex:1];
|
||||
if ([eventLabel isKindOfClass:[NSNull class]]) {
|
||||
eventLabel = nil;
|
||||
}
|
||||
[MobClick event:eventId label:eventLabel];
|
||||
}
|
||||
|
||||
- (void)onEventWithParameters:(CDVInvokedUrlCommand*)command {
|
||||
NSString *eventId = [command.arguments objectAtIndex:0];
|
||||
if (eventId == nil || [eventId isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
NSDictionary *parameters = [command.arguments objectAtIndex:1];
|
||||
if (parameters == nil && [parameters isKindOfClass:[NSNull class]]) {
|
||||
parameters = nil;
|
||||
}
|
||||
[MobClick event:eventId attributes:parameters];
|
||||
}
|
||||
|
||||
- (void)onEventWithCounter:(CDVInvokedUrlCommand*)command {
|
||||
NSString *eventId = [command.arguments objectAtIndex:0];
|
||||
if (eventId == nil || [eventId isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
NSDictionary *parameters = [command.arguments objectAtIndex:1];
|
||||
if (parameters == nil && [parameters isKindOfClass:[NSNull class]]) {
|
||||
parameters = nil;
|
||||
}
|
||||
NSString *eventNum = [command.arguments objectAtIndex:2];
|
||||
if (eventNum == nil && [eventNum isKindOfClass:[NSNull class]]) {
|
||||
eventNum = nil;
|
||||
}
|
||||
int num = [eventNum intValue];
|
||||
[MobClick event:eventId attributes:parameters counter:num];
|
||||
}
|
||||
|
||||
- (void)onPageBegin:(CDVInvokedUrlCommand*)command {
|
||||
NSString *pageName = [command.arguments objectAtIndex:0];
|
||||
if (pageName == nil || [pageName isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
[MobClick beginLogPageView:pageName];
|
||||
}
|
||||
|
||||
- (void)onPageEnd:(CDVInvokedUrlCommand*)command {
|
||||
NSString *pageName = [command.arguments objectAtIndex:0];
|
||||
if (pageName == nil || [pageName isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
[MobClick endLogPageView:pageName];
|
||||
}
|
||||
|
||||
- (void)profileSignInWithPUID:(CDVInvokedUrlCommand*)command {
|
||||
NSString *puid = [command.arguments objectAtIndex:0];
|
||||
if (puid == nil || [puid isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
[MobClickGameAnalytics profileSignInWithPUID:puid];
|
||||
}
|
||||
|
||||
- (void)profileSignInWithPUIDWithProvider:(CDVInvokedUrlCommand*)command {
|
||||
NSString *provider = [command.arguments objectAtIndex:0];
|
||||
if (provider == nil && [provider isKindOfClass:[NSNull class]]) {
|
||||
provider = nil;
|
||||
}
|
||||
NSString *puid = [command.arguments objectAtIndex:1];
|
||||
if (puid == nil || [puid isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
|
||||
[MobClickGameAnalytics profileSignInWithPUID:puid provider:provider];
|
||||
}
|
||||
|
||||
- (void)profileSignOff:(NSArray *)arguments {
|
||||
[MobClickGameAnalytics profileSignOff];
|
||||
|
||||
}
|
||||
//游戏统计
|
||||
|
||||
- (void)setUserLevelId:(CDVInvokedUrlCommand*)command {
|
||||
NSString *level = [command.arguments objectAtIndex:0];
|
||||
if (level == nil || [level isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
int levelValue = [level intValue];
|
||||
[MobClickGameAnalytics setUserLevelId:levelValue];
|
||||
}
|
||||
|
||||
- (void)startLevel:(CDVInvokedUrlCommand*)command {
|
||||
NSString *level = [command.arguments objectAtIndex:0];
|
||||
if (level == nil || [level isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
[MobClickGameAnalytics startLevel:level];
|
||||
}
|
||||
|
||||
- (void)finishLevel:(CDVInvokedUrlCommand*)command {
|
||||
NSString *level = [command.arguments objectAtIndex:0];
|
||||
if (level == nil || [level isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
[MobClickGameAnalytics finishLevel:level];
|
||||
}
|
||||
|
||||
- (void)failLevel:(CDVInvokedUrlCommand*)command {
|
||||
NSString *level = [command.arguments objectAtIndex:0];
|
||||
if (level == nil || [level isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
[MobClickGameAnalytics failLevel:level];
|
||||
}
|
||||
|
||||
- (void)exchange:(CDVInvokedUrlCommand*)command {
|
||||
|
||||
NSString *currencyAmount = [command.arguments objectAtIndex:0];
|
||||
if (currencyAmount == nil && [currencyAmount isKindOfClass:[NSNull class]]) {
|
||||
currencyAmount = nil;
|
||||
}
|
||||
NSString *currencyType = [command.arguments objectAtIndex:1];
|
||||
if (currencyType == nil && [currencyType isKindOfClass:[NSNull class]]) {
|
||||
currencyType = nil;
|
||||
}
|
||||
NSString *virtualAmount = [command.arguments objectAtIndex:2];
|
||||
if (virtualAmount == nil && [virtualAmount isKindOfClass:[NSNull class]]) {
|
||||
virtualAmount = nil;
|
||||
}
|
||||
NSString *channel = [command.arguments objectAtIndex:3];
|
||||
if (channel == nil && [channel isKindOfClass:[NSNull class]]) {
|
||||
channel = nil;
|
||||
}
|
||||
NSString *orderId = [command.arguments objectAtIndex:4];
|
||||
if (orderId == nil || [orderId isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
double currencyAmountDouble = [currencyAmount doubleValue];
|
||||
double virtualAmountDouble = [virtualAmount doubleValue];
|
||||
int channelInt = [channel intValue];
|
||||
[MobClickGameAnalytics exchange:orderId currencyAmount:currencyAmountDouble currencyType:currencyType virtualCurrencyAmount:virtualAmountDouble paychannel:channelInt];
|
||||
}
|
||||
|
||||
- (void)pay:(CDVInvokedUrlCommand*)command {
|
||||
NSString *cash = [command.arguments objectAtIndex:0];
|
||||
if (cash == nil || [cash isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
NSString *coin = [command.arguments objectAtIndex:1];
|
||||
if (coin == nil && [coin isKindOfClass:[NSNull class]]) {
|
||||
coin = nil;
|
||||
}
|
||||
NSString *source = [command.arguments objectAtIndex:2];
|
||||
if (source == nil && [source isKindOfClass:[NSNull class]]) {
|
||||
source = nil;
|
||||
}
|
||||
|
||||
|
||||
double cashDouble = [cash doubleValue];
|
||||
int sourceInt = [source doubleValue];
|
||||
double coinDouble = [coin doubleValue];
|
||||
[MobClickGameAnalytics pay:cashDouble source:sourceInt coin:coinDouble];
|
||||
}
|
||||
|
||||
- (void)payWithItem:(CDVInvokedUrlCommand*)command {
|
||||
NSString *cash = [command.arguments objectAtIndex:0];
|
||||
if (cash == nil || [cash isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
NSString *item = [command.arguments objectAtIndex:1];
|
||||
if (item == nil && [item isKindOfClass:[NSNull class]]) {
|
||||
item = nil;
|
||||
}
|
||||
NSString *amount = [command.arguments objectAtIndex:2];
|
||||
if (amount == nil && [amount isKindOfClass:[NSNull class]]) {
|
||||
amount = nil;
|
||||
}
|
||||
NSString *price = [command.arguments objectAtIndex:3];
|
||||
if (price == nil && [price isKindOfClass:[NSNull class]]) {
|
||||
price = nil;
|
||||
}
|
||||
NSString *source = [command.arguments objectAtIndex:4];
|
||||
if (source == nil && [source isKindOfClass:[NSNull class]]) {
|
||||
source = nil;
|
||||
}
|
||||
double cashDoule = [cash doubleValue];
|
||||
int sourceInt = [source intValue];
|
||||
int amountInt = [amount intValue];
|
||||
double priceDouble = [price doubleValue];
|
||||
[MobClickGameAnalytics pay:cashDoule source:sourceInt item:item amount:amountInt price:priceDouble];
|
||||
}
|
||||
|
||||
- (void)buy:(CDVInvokedUrlCommand*)command {
|
||||
NSString *item = [command.arguments objectAtIndex:0];
|
||||
if (item == nil || [item isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
NSString *amount = [command.arguments objectAtIndex:1];
|
||||
if (amount == nil && [amount isKindOfClass:[NSNull class]]) {
|
||||
amount = nil;
|
||||
}
|
||||
NSString *price = [command.arguments objectAtIndex:2];
|
||||
if (price == nil && [price isKindOfClass:[NSNull class]]) {
|
||||
price = nil;
|
||||
}
|
||||
|
||||
int amountInt = [amount doubleValue];
|
||||
double priceDouble = [price doubleValue];
|
||||
[MobClickGameAnalytics buy:item amount:amountInt price:priceDouble];
|
||||
}
|
||||
|
||||
- (void)use:(CDVInvokedUrlCommand*)command {
|
||||
NSString *item = [command.arguments objectAtIndex:0];
|
||||
if (item == nil || [item isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
NSString *amount = [command.arguments objectAtIndex:1];
|
||||
if (amount == nil && [amount isKindOfClass:[NSNull class]]) {
|
||||
amount = nil;
|
||||
}
|
||||
NSString *price = [command.arguments objectAtIndex:2];
|
||||
if (price == nil && [price isKindOfClass:[NSNull class]]) {
|
||||
price = nil;
|
||||
}
|
||||
|
||||
int amountInt = [amount doubleValue];
|
||||
double priceDouble = [price doubleValue];
|
||||
[MobClickGameAnalytics use:item amount:amountInt price:priceDouble];
|
||||
}
|
||||
|
||||
- (void)bonus:(CDVInvokedUrlCommand*)command {
|
||||
NSString *coin = [command.arguments objectAtIndex:0];
|
||||
if (coin == nil || [coin isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
NSString *source = [command.arguments objectAtIndex:1];
|
||||
if (source == nil && [source isKindOfClass:[NSNull class]]) {
|
||||
source = nil;
|
||||
}
|
||||
|
||||
double coinDouble = [coin doubleValue];
|
||||
int sourceInt = [source doubleValue];
|
||||
[MobClickGameAnalytics bonus:coinDouble source:sourceInt];
|
||||
}
|
||||
|
||||
- (void)bonusWithItem:(CDVInvokedUrlCommand*)command {
|
||||
NSString *item = [command.arguments objectAtIndex:0];
|
||||
if (item == nil || [item isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
NSString *amount = [command.arguments objectAtIndex:1];
|
||||
if (amount == nil && [amount isKindOfClass:[NSNull class]]) {
|
||||
amount = nil;
|
||||
}
|
||||
NSString *price = [command.arguments objectAtIndex:2];
|
||||
if (price == nil && [price isKindOfClass:[NSNull class]]) {
|
||||
price = nil;
|
||||
}
|
||||
NSString *source = [command.arguments objectAtIndex:3];
|
||||
if (source == nil && [source isKindOfClass:[NSNull class]]) {
|
||||
source = nil;
|
||||
}
|
||||
|
||||
int amountInt = [amount doubleValue];
|
||||
double priceDouble = [price doubleValue];
|
||||
int sourceInt = [source doubleValue];
|
||||
[MobClickGameAnalytics bonus:item amount:amountInt price:priceDouble source:sourceInt];
|
||||
}
|
||||
|
||||
//Dplus
|
||||
- (void)track:(CDVInvokedUrlCommand*)command {
|
||||
NSString *eventName = [command.arguments objectAtIndex:0];
|
||||
if (eventName == nil || [eventName isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
[DplusMobClick track:eventName];
|
||||
}
|
||||
|
||||
- (void)trackWithProperty:(CDVInvokedUrlCommand*)command {
|
||||
NSString *eventName = [command.arguments objectAtIndex:0];
|
||||
if (eventName == nil || [eventName isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
NSDictionary *property = [command.arguments objectAtIndex:1];
|
||||
[DplusMobClick track:eventName property:property];
|
||||
}
|
||||
|
||||
- (void)registerSuperProperty:(CDVInvokedUrlCommand*)command {
|
||||
NSDictionary *property = [command.arguments objectAtIndex:0];
|
||||
[DplusMobClick registerSuperProperty:property];
|
||||
}
|
||||
|
||||
- (void)unregisterSuperProperty:(CDVInvokedUrlCommand*)command {
|
||||
NSString *propertyName = [command.arguments objectAtIndex:0];
|
||||
if (propertyName == nil || [propertyName isKindOfClass:[NSNull class]]) {
|
||||
return;
|
||||
}
|
||||
[DplusMobClick unregisterSuperProperty:propertyName];
|
||||
}
|
||||
|
||||
- (void)getSuperProperty:(CDVInvokedUrlCommand*)command {
|
||||
NSString *propertyName = [command.arguments objectAtIndex:0];
|
||||
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[DplusMobClick getSuperProperty:propertyName]];
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)getSuperProperties:(CDVInvokedUrlCommand*)command {
|
||||
|
||||
NSString *jsonString = nil;
|
||||
NSError *error = nil;
|
||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[DplusMobClick getSuperProperties]
|
||||
options:kNilOptions //TODO: NSJSONWritingPrettyPrinted // kNilOptions
|
||||
error:&error];
|
||||
if ([jsonData length] && (error == nil))
|
||||
{
|
||||
jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding] ;
|
||||
}else{
|
||||
jsonString=@"";
|
||||
}
|
||||
NSString *callBack = [NSString stringWithFormat:@"getSuperProperties('%@')",jsonString];
|
||||
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:callBack];
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||
|
||||
}
|
||||
|
||||
- (void)clearSuperProperties:(CDVInvokedUrlCommand*)commands {
|
||||
[DplusMobClick clearSuperProperties];
|
||||
}
|
||||
|
||||
- (void)setFirstLaunchEvent:(CDVInvokedUrlCommand*)command {
|
||||
NSArray *eventList = [command.arguments objectAtIndex:0];
|
||||
[DplusMobClick setFirstLaunchEvent:eventList];
|
||||
}
|
||||
|
||||
@end
|
||||
1
src/ios/UMCommon.framework/1.4.1_9ef40535dc_20171220164154
Executable file
1
src/ios/UMCommon.framework/1.4.1_9ef40535dc_20171220164154
Executable file
@@ -0,0 +1 @@
|
||||
1.4.1
|
||||
1
src/ios/UMCommon.framework/Headers
Symbolic link
1
src/ios/UMCommon.framework/Headers
Symbolic link
@@ -0,0 +1 @@
|
||||
Versions/Current/Headers
|
||||
1
src/ios/UMCommon.framework/UMCommon
Symbolic link
1
src/ios/UMCommon.framework/UMCommon
Symbolic link
@@ -0,0 +1 @@
|
||||
Versions/Current/UMCommon
|
||||
19
src/ios/UMCommon.framework/Versions/A/Headers/UMCommon.h
Executable file
19
src/ios/UMCommon.framework/Versions/A/Headers/UMCommon.h
Executable file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// UMCommon.h
|
||||
// UMCommon
|
||||
//
|
||||
// Created by San Zhang on 11/2/16.
|
||||
// Copyright © 2016 UMeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
//! Project version number for UMCommon.
|
||||
FOUNDATION_EXPORT double UMCommonVersionNumber;
|
||||
|
||||
//! Project version string for UMCommon.
|
||||
FOUNDATION_EXPORT const unsigned char UMCommonVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <UMCommon/PublicHeader.h>
|
||||
|
||||
#import <UMCommon/UMConfigure.h>
|
||||
41
src/ios/UMCommon.framework/Versions/A/Headers/UMConfigure.h
Executable file
41
src/ios/UMCommon.framework/Versions/A/Headers/UMConfigure.h
Executable file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// UMConfigure.h
|
||||
// UMCommon
|
||||
//
|
||||
// Created by San Zhang on 9/6/16.
|
||||
// Copyright © 2016 UMeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface UMConfigure : NSObject
|
||||
|
||||
/** 初始化友盟所有组件产品
|
||||
@param appKey 开发者在友盟官网申请的appkey.
|
||||
@param channel 渠道标识,可设置nil表示"App Store".
|
||||
@return;
|
||||
*/
|
||||
+ (void)initWithAppkey:(NSString *)appKey channel:(NSString *)channel;
|
||||
|
||||
/** 设置是否在console输出sdk的log信息.
|
||||
@param bFlag 默认NO(不输出log); 设置为YES, 输出可供调试参考的log信息. 发布产品时必须设置为NO.
|
||||
@return void.
|
||||
*/
|
||||
+ (void)setLogEnabled:(BOOL)bFlag;
|
||||
|
||||
/** 设置是否对日志信息进行加密, 默认NO(不加密).
|
||||
@param value 设置为YES, umeng SDK 会将日志信息做加密处理
|
||||
@return void.
|
||||
*/
|
||||
+ (void)setEncryptEnabled:(BOOL)value;
|
||||
|
||||
+ (NSString *)umidString;
|
||||
|
||||
/**
|
||||
集成测试需要device_id
|
||||
*/
|
||||
+ (NSString*)deviceIDForIntegration;
|
||||
|
||||
|
||||
|
||||
@end
|
||||
BIN
src/ios/UMCommon.framework/Versions/A/UMCommon
Executable file
BIN
src/ios/UMCommon.framework/Versions/A/UMCommon
Executable file
Binary file not shown.
1
src/ios/UMCommon.framework/Versions/Current
Symbolic link
1
src/ios/UMCommon.framework/Versions/Current
Symbolic link
@@ -0,0 +1 @@
|
||||
A
|
||||
12
src/ios/UMCommonModule.h
Executable file
12
src/ios/UMCommonModule.h
Executable file
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// UMCommonModule.h
|
||||
// PhoneGap_Component
|
||||
//
|
||||
// Created by wangfei on 2017/10/11.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UMCommon/UMCommon.h>
|
||||
@interface UMCommonModule : NSObject
|
||||
+ (void)initWithAppkey:(NSString *)appkey channel:(NSString *)channel;
|
||||
@end
|
||||
19
src/ios/UMCommonModule.m
Normal file
19
src/ios/UMCommonModule.m
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// UMCommonModule.m
|
||||
// PhoneGap_Component
|
||||
//
|
||||
// Created by wangfei on 2017/10/11.
|
||||
//
|
||||
|
||||
#import "UMCommonModule.h"
|
||||
|
||||
@implementation UMCommonModule
|
||||
+ (void)initWithAppkey:(NSString *)appkey channel:(NSString *)channel
|
||||
{
|
||||
SEL sel = NSSelectorFromString(@"setWraperType:wrapperVersion:");
|
||||
if ([UMConfigure respondsToSelector:sel]) {
|
||||
[UMConfigure performSelector:sel withObject:@"react-native" withObject:@"1.0"];
|
||||
}
|
||||
[UMConfigure initWithAppkey:appkey channel:channel];
|
||||
}
|
||||
@end
|
||||
356
www/analyticssdk.js
Normal file
356
www/analyticssdk.js
Normal file
@@ -0,0 +1,356 @@
|
||||
/*
|
||||
* Javascript interface of Cordova plugin for Umeng Analytics SDK
|
||||
*/
|
||||
|
||||
var MobclickAgent = {
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
* @param appKey appKey
|
||||
* @param channelId 渠道号
|
||||
*/
|
||||
init:function(appKey,channelId) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "init", [appKey, channelId]);
|
||||
},
|
||||
|
||||
/**
|
||||
* 自定义事件数量统计
|
||||
*
|
||||
* @param eventId
|
||||
* String类型.事件ID,注意需要先在友盟网站注册此ID
|
||||
*/
|
||||
onEvent : function(eventId) {
|
||||
cordova.exec(null, null, "AnalyticsSDK","onEvent", [ eventId ]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 自定义事件数量统计
|
||||
*
|
||||
* @param eventId
|
||||
* String类型.事件ID, 注意需要先在友盟网站注册此ID
|
||||
* @param eventLabel
|
||||
* String类型.事件标签,事件的一个属性说明
|
||||
*/
|
||||
onEventWithLabel : function(eventId, eventLabel) {
|
||||
cordova.exec(null, null, "AnalyticsSDK","onEventWithLabel", [ eventId, eventLabel ]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 自定义事件数量统计
|
||||
*
|
||||
* @param eventId
|
||||
* String类型.事件ID, 注意需要先在友盟网站注册此ID
|
||||
* @param eventData
|
||||
* Dictionary类型.当前事件的属性集合,最多支持10个K-V值
|
||||
*/
|
||||
onEventWithParameters : function(eventId, eventData) {
|
||||
cordova.exec(null, null, "AnalyticsSDK","onEventWithParameters", [ eventId, eventData ]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 自定义事件数值型统计
|
||||
*
|
||||
* @param eventId
|
||||
* String类型.事件ID,注意要先在友盟网站上注册此事件ID
|
||||
* @param eventData
|
||||
* Dictionary类型.事件的属性集合,最多支持10个K-V值
|
||||
* @param eventNum
|
||||
* int 类型.事件持续时长,单位毫秒,您需要手动计算并传入时长,作为事件的时长参数
|
||||
*
|
||||
*/
|
||||
onEventWithCounter : function(eventId, eventData, eventNum) {
|
||||
cordova.exec(null, null, "AnalyticsSDK","onEventWithCounter", [ eventId, eventData, eventNum ]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 页面统计开始时调用
|
||||
*
|
||||
* @param pageName
|
||||
* String类型.页面名称
|
||||
*/
|
||||
onPageBegin : function(pageName) {
|
||||
cordova.exec(null, null, "AnalyticsSDK","onPageBegin", [ pageName ]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 页面统计结束时调用
|
||||
*
|
||||
* @param pageName
|
||||
* String类型.页面名称
|
||||
*/
|
||||
onPageEnd : function(pageName) {
|
||||
cordova.exec(null, null, "AnalyticsSDK","onPageEnd", [ pageName ]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 获取IOS UUID
|
||||
*/
|
||||
getDeviceId:function(callBack) {
|
||||
cordova.exec(callBack, null, "AnalyticsSDK", "getDeviceId", []);
|
||||
|
||||
},
|
||||
/**
|
||||
* 在控制台打印log
|
||||
* @param enabled
|
||||
* Bool类型
|
||||
*/
|
||||
setLogEnabled:function(enabled) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "setLogEnabled", [enabled]);
|
||||
},
|
||||
/**
|
||||
* 统计帐号登录接口 *
|
||||
*
|
||||
* @param UID
|
||||
* 用户账号ID,长度小于64字节
|
||||
*/
|
||||
profileSignInWithPUID:function(UID) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "profileSignInWithPUID", [UID]);
|
||||
},
|
||||
/**
|
||||
* 统计帐号登录接口 *
|
||||
*
|
||||
* @param provider
|
||||
* 帐号来源.用户通过第三方账号登陆,可以调用此接口进行统计.不能以下划线"_"开头,使用大写字母和数字标识,长度小于32字节;
|
||||
* 如果是上市公司,建议使用股票代码.
|
||||
* @param UID
|
||||
* 用户账号ID,长度小于64字节
|
||||
*/
|
||||
profileSignInWithPUIDWithProvider:function(provider, UID) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "profileSignInWithPUIDWithProvider", [ provider, UID ]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 帐号统计退出接口
|
||||
*/
|
||||
profileSignOff:function(){
|
||||
cordova.exec(null, null, "AnalyticsSDK", "profileSignOff", []);
|
||||
|
||||
},
|
||||
/**
|
||||
* 当玩家建立角色或者升级时,需调用此接口
|
||||
*
|
||||
* @param level
|
||||
* int类型.等级
|
||||
*/
|
||||
setUserLevelId:function(level) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "setUserLevelId", [level]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 游戏中关卡开始的时候调用此方法。
|
||||
*
|
||||
* @param level
|
||||
* String类型.
|
||||
*/
|
||||
startLevel:function(level) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "startLevel", [level]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 游戏中成功过关的时候调用此方法
|
||||
*
|
||||
* @param level
|
||||
* String类型.
|
||||
*/
|
||||
finishLevel:function(level) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "finishLevel", [level]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 游戏中在某一关卡失败的时候调用此方法
|
||||
*
|
||||
* @param level
|
||||
* String类型.
|
||||
*/
|
||||
|
||||
failLevel:function(level) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "failLevel", [level]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 统计订单的接口
|
||||
*
|
||||
* @param currencyAmount
|
||||
* double类型.货币金额
|
||||
* @param currencyType
|
||||
* String类型.货币类型
|
||||
* @param virtualAmount
|
||||
* double类型.虚拟货币金额
|
||||
* @param channel
|
||||
* int类型.
|
||||
* </p>
|
||||
* 本次消费的途径:1.AppStore 2.支付宝 3.网银 4.财付通 5.移动 6.联通 7.电信 8.paypal
|
||||
* @param orderId
|
||||
* String类型.订单ID
|
||||
*/
|
||||
|
||||
exchange:function(currencyAmount,currencyType,virtualAmount,channel,orderId) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "exchange", [currencyAmount,currencyType,virtualAmount,channel,orderId]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 游戏中真实消费(充值)的时候调用此方法 1.AppStore 2.支付宝 3.网银 4.财付通 5.移动 6.联通 7.电信 8.paypal
|
||||
*
|
||||
* @param money
|
||||
* double类型.本次消费金额
|
||||
* @param coin
|
||||
* double类型.本次消费等值的虚拟币
|
||||
* @param source
|
||||
* int类型.本次消费的途径,网银,支付宝 等
|
||||
*/
|
||||
|
||||
pay:function(money, coin, source) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "pay", [ money, coin, source ]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 游戏中真实消费(购买物品)的时候调用此方法
|
||||
*
|
||||
* @param money
|
||||
* double类型.本地消费金额
|
||||
* @param item
|
||||
* String类型. 本次购买物品名称
|
||||
* @param number
|
||||
* int类型.本地购买物品数量
|
||||
* @param price
|
||||
* double类型.本地购买等值虚拟币
|
||||
* @param source
|
||||
* int类型.本次消费的途径,网银支付宝等
|
||||
*/
|
||||
payWithItem:function(money, item, number, price, source) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "payWithItem", [ money, item, number, price, source ]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 游戏中虚拟消费(购买物品)的时候调用此方法
|
||||
*
|
||||
* @param item
|
||||
* String类型.本地购买的物品名称
|
||||
* @param number
|
||||
* int类型.本地购买的物品数量
|
||||
* @param price
|
||||
* double类型.本地购买花费的虚拟币数量
|
||||
*/
|
||||
|
||||
buy : function(item, number, price) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "buy", [ item, number, price ]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 游戏中使用道具时候调用此方法
|
||||
*
|
||||
* @param item
|
||||
* String类型. 道具名称
|
||||
* @param number
|
||||
* int类型. 数量
|
||||
* @param price
|
||||
* double类型.等值虚拟币
|
||||
*/
|
||||
use : function(item, number, price) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "use", [ item, number, price ]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 游戏中免费获得额外金币时调用此方法
|
||||
*
|
||||
* @param coin
|
||||
* double类型. 奖励金币数额
|
||||
* @param source
|
||||
* int类型.奖励金币的触发原因
|
||||
*/
|
||||
|
||||
bonus : function(coin, source) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "bonus", [ coin, source ]);
|
||||
|
||||
},
|
||||
/**
|
||||
* 游戏中免费获得额外金币时调用此方法
|
||||
*
|
||||
* @param item
|
||||
* String类型. 道具名称
|
||||
* @param number
|
||||
* int类型. 数量
|
||||
* @param price
|
||||
* double类型.等值虚拟币
|
||||
* @param source
|
||||
* int类型.本次消费的途径,网银支付宝等
|
||||
*/
|
||||
|
||||
bonusWithItem : function(item, number, price, source) {
|
||||
cordova.exec(null, null, "AnalyticsSDK", "bonusWithItem", [ item, number, price, source ]);
|
||||
|
||||
},
|
||||
/** Dplus增加事件
|
||||
* @param eventName 事件名
|
||||
* String类型.事件名
|
||||
*
|
||||
*/
|
||||
track : function(eventName) {
|
||||
cordova.exec(null, null, "AnalyticsSDK","track", [ eventName ]);
|
||||
},
|
||||
|
||||
/** Dplus增加事件
|
||||
* @param eventName
|
||||
* String类型.事件名
|
||||
* @param property
|
||||
* Dictionary类型.自定义属性
|
||||
*
|
||||
*/
|
||||
trackWithProperty : function(eventName, property) {
|
||||
cordova.exec(null, null, "AnalyticsSDK","trackWithProperty", [ eventName, property]);
|
||||
},
|
||||
|
||||
/** * 设置属性 键值对 会覆盖同名的key
|
||||
* 将该函数指定的key-value写入dplus专用文件;APP启动时会自动读取该文件的所有key-value,并将key-value自动作为后续所有track事件的属性。
|
||||
* @param property
|
||||
* Dictionary类型.自定义属性
|
||||
*
|
||||
*/
|
||||
registerSuperProperty : function(property) {
|
||||
cordova.exec(null, null, "AnalyticsSDK","registerSuperProperty", [property]);
|
||||
},
|
||||
|
||||
/** * 从dplus专用文件中删除指定key-value
|
||||
* @param propertyName
|
||||
* String类型.自定义属性
|
||||
*
|
||||
*/
|
||||
unregisterSuperProperty : function(propertyName) {
|
||||
cordova.exec(null, null, "AnalyticsSDK","unregisterSuperProperty", [propertyName]);
|
||||
},
|
||||
|
||||
/** 返回dplus专用文件中key对应的value;如果不存在,则返回空
|
||||
* @param propertyName
|
||||
* String类型.自定义属性
|
||||
*
|
||||
*/
|
||||
getSuperProperty : function(callBack,propertyName) {
|
||||
cordova.exec(callBack, null, "AnalyticsSDK","getSuperProperty", [propertyName]);
|
||||
},
|
||||
|
||||
/** 返回Dplus专用文件中的所有key-value;如果不存在,则返回空。
|
||||
*
|
||||
*/
|
||||
getSuperProperties : function(callBack) {
|
||||
cordova.exec(callBack, null, "AnalyticsSDK","getSuperProperties", []);
|
||||
},
|
||||
|
||||
/** * 清空Dplus专用文件中的所有key-value。
|
||||
*
|
||||
*/
|
||||
clearSuperProperties : function() {
|
||||
cordova.exec(null, null, "AnalyticsSDK","clearSuperProperties", []);
|
||||
},
|
||||
|
||||
/** * 设置关注事件是否首次触发,只关注eventList前五个合法eventID.只要已经保存五个,此接口无效
|
||||
* @param eventList
|
||||
* Array类型.自定义属性
|
||||
*
|
||||
*/
|
||||
setFirstLaunchEvent : function(eventList) {
|
||||
cordova.exec(null, null, "AnalyticsSDK","setFirstLaunchEvent", [eventList]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = MobclickAgent;
|
||||
Reference in New Issue
Block a user