Skip to content

rj9676564/baidumobstat-react-native

 
 

Repository files navigation

baidumobstat-react-native

iOS

  • 新建一个React Native工程,参考React Native 官网

    react-native init hello
    cd hello
    yarn add baidumobstat-react-native
    react-native link
  • 在iOS工程的Linked Frameworks and Libraries, 加入以下依赖

     libz.tbd
     libc++.tbd
     libicucore.tbd
    
  • 在 iOS 工程中如果找不到头文件可能要在 TARGETS-> BUILD SETTINGS -> Search Paths -> Header Search Paths 添加如下路径

    $(SRCROOT)/../node_modules/baidumobstat-react-native/ios/RCTBaiduMobStat/RCTBaiduMobStat
    
  • 打开ios下的工程,在AppDelegate.m内添加百度移动统计的启动代码

    #import "BaiduMobStat.h"
    
    // - (BOOL)application: didFinishLaunchingWithOptions:
    [[BaiduMobStat defaultStat] startWithAppId:@"xxx"];
  • 在App.js 内使用对应的接口

Android

  • 新建一个React Native工程,参考React Native 官网,添加百度移动统计react native插件支持

     react-native install baidumobstat-react-native
     react-native link baidumobstat-react-native
    
  • Application中注册sdk package

     @Override
     protected List<ReactPackage> getPackages() {
         ReactPackage packages[] = new ReactPackage[]{
             new MainReactPackage(),
             new RNBaiduMobStatPackage()
         };
         return Arrays.<ReactPackage>asList(packages);
     }
    
  • 在App.js 内使用对应的接口埋点,完成统计

About

百度移动统计ReactNative插件

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 59.0%
  • Java 19.1%
  • JavaScript 16.3%
  • Starlark 4.2%
  • Ruby 1.4%