@cross2d/react-native-talkingdata

2.10.1 • Public • Published

react-native-talkingdata

React Native的TalkingData插件

如何安装

首先安装npm包

npm install @cross2d/react-native-talkingdata --save

link

rnpm link

Note: rnpm requires node version 4.1 or higher

自动link注意

Android版本需要手动修改如下配置

app/build.gradle中 
compile project(':@cross2d/react-native-talkingdata')
修改为
compile project(':react-native-talkingdata')

项目的 settings.gradle
include ':@cross2d/react-native-talkingdata'
project(':@cross2d/react-native-talkingdata').projectDir = new File(rootProject.projectDir, '../node_modules/@cross2d/react-native-talkingdata/android')
需要修改为  
include ':react-native-talkingdata'
project(':react-native-talkingdata').projectDir = new File(rootProject.projectDir, '../node_modules/@cross2d/react-native-talkingdata/android')

iOS工程配置

在工程target的Build Phases->Link Binary with Libraries中加入、CoreTelephony.framework、AdSupport.framework、SystemConfiguration.framework、Security.framework、CoreMotion.framework、liz.tbd

在你工程的AppDelegate.m文件中添加如下代码:

#import "RCTTalkingData.h"


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
	// 添加在第一行
  [RCTTalkingData registerApp:@"APPID" channelID:@"渠道号" crashReport:YES];
  ...
  ...

}

安装Android工程

android/app/build.gradle里,defaultConfig栏目下添加如下代码:

	manifestPlaceholders = [
           TD_APPID: "talkingdata的APPID",//在此修改为你的TalkingData APPID
           APP_CHANNEL: "渠道号",
   	]

在你自定义的MainApplication的getPackages()函数 return Arrays.asList 中加入

	new TalkingDataPackage(),

注意导入 talkingdata的对应包

	import cn.reactnative.modules.talkingdata.TalkingDataPackage;

在你自定义的MainActivity的onCreate()中第一行加入

	TalkingDataModule.register(getApplicationContext(), null, null, true);

如何使用

引入包

import * as TD from 'react-native-talkingdata';

API

TD.trackPageBegin(page_name)

TD.trackPageEnd(page_name)

TD.trackEvent(event_name, event_label, parameters)

TD.setLocation(latitude, longitude)

TD.getDeviceID()

Package Sidebar

Install

npm i @cross2d/react-native-talkingdata

Weekly Downloads

1

Version

2.10.1

License

ISC

Unpacked Size

14.8 MB

Total Files

18

Last publish

Collaborators

  • colin3dmax