0.0.16 • Published 8 years ago

maxleap-react-native v0.0.16

Weekly downloads
1
License
ISC
Repository
github
Last release
8 years ago

MaxLeap SDK RN npm version

安装 SDK

npm install --save maxleap-react-native

集成 iOS 环境

  1. 打开 Finder, 导航到当前项目根目录,进入 node_modules/maxleap-react-native/ios/lib 文件夹,把这个文件夹下的 frameworks 都添加到 Xcode 工程中。
  2. 在弹出的对话框中的 Added folders 选项上选择 Create groups,点击 Finish
  3. 添加依赖 确保“Enable Modules (C and Objective-C)” 和 “Link Frameworks Automatically”的生成设置为 Yes。

    点击 Targets → YourAppName → "Build Phases" 栏。 展开 “Link Binary With Libraries”

    点击 "Link Binary With Libraries" 左下角+号按钮,添加下列框架:

    MobileCoreServices.framework CoreTelephony.framework SystemConfiguration.framework libsqlite3.dylib libz.dylib

  4. 添加 Framework Search Paths

    在 Xcode 中,导航到 Targets -> YourAppName -> "Build Settings",找到 “Framework Search Paths” 一项,添加下面这个路径:

    $(SRCROOT)/../node_modules/maxleap-react-native/ios/lib

  5. 修改 AppDelegate.m 文件

    加入以下代码:

    #import <MaxLeap/MaxLeap.h>
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
        [MaxLeap setApplicationId:@"your_maxleap_appId" 
                      clientKey:@"your_maxleap_clientKey"
      					 	   site:MLSiteCN];
      	// your code ...
    }

集成 Android 环境

  1. 修改父工程目录下的 build.gradle 文件(与 settings.gradle 位于同级目录)。

    repositories {
        flatDir{
            dirs '../../node_modules/maxleap-react-native/dist/android'
        }
    }
  2. 修改应用目录下的 build.gradle 文件,添加以下依赖

    dependencies {
        compile(name:'maxleap-react-native', ext:'aar')
    }
  3. 修改工程的主 Activity 文件。

    private MaxLeap maxLeap;
    
     @Override
    protected void onCreate(Bundle savedInstanceState) {
        // 确保在 super.onCreate() 之前调用以下代码
        maxLeap = new MaxLeap(this, APP_ID, API_KEY);
        super.onCreate(savedInstanceState);
    }
    
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
                new MainReactPackage(),
                maxLeap.getReactPackage()
        );
    }

使用 SDK

import ML from 'maxleap-react-native';
ML.useCNServer();

详细使用方法请参阅 MaxLeap 文档

0.0.16

8 years ago

0.0.15

8 years ago

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago