react-native-geyan
TypeScript icon, indicating that this package has built-in type declarations

0.5.0 • Public • Published

react-native-geyan

个推“个验·一键认证”React-Native 原生模块

Installation

yarn add react-native-geyan

Setup

在使用此模块前请先在个推管理后台完成应用创建

Android

编辑android/app/build.gradle,添加appIdchannel

android {
  ...
  defaultConfig {
    ...
    manifestPlaceholders = [
      GETUI_APPID: "your app id",
      GT_INSTALL_CHANNEL: "getui" // your channel
    ]
  }
}

确保applicationId与应用后台 Android 包名一致 确保后台填写的**Android 签名(MD5)**和应用使用的keystore文件保持一致

iOS

确保Bundle Identifier和个验后台配置一致

Usage

import { open, init, close, isPreLoginResultValid } from 'react-native-geyan';
const logo = require('./assets/logo.png');

init({
  appid: 'your appid',
});

async function startELogin() {
  if (!isPreLoginResultValid()) {
    return;
  }
  try {
    const token = await open({
      logo,
    });
    console.log(token: `${token}`)
  } catch(e) {
    // ...
  }
  // iOS only
  await close();
}

iOS 需要手动调用close关闭一键登录页面

更详细的使用方式见example

API

init(config: GeyanInitConfig): Promise<string>

interface GeyanInitConfig {
  /**
   * 渠道(Android only)
   */
  channel?: string;
  /**
   * appid(iOS only)
   */
  appid: string;
}

初始化 SDK 并进行预登录

open(config: GeyanConfig): Promise<GeyanResult>

interface GeyanConfig {
  /**
   * 应用图标(用于一键登录页logo露出)
   */
  logo: ImageSourcePropType;
  /**
   * 自定义的隐私策略 (Android only) (若无请传空数组)
   */
  privacy?: PrivacyItem[];
}

打开一键登录页,成功后返回token

close(): Promise

关闭一键登录页面

仅 iOS 支持

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

Package Sidebar

Install

npm i react-native-geyan

Weekly Downloads

144

Version

0.5.0

License

MIT

Unpacked Size

68.9 MB

Total Files

68

Last publish

Collaborators

  • limoer