JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q44741F
  • License ISC

MaxLeap SDK for ReactNative

Package Exports

  • maxleap-react-native

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (maxleap-react-native) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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 文档