1.3.1 • Published 4 months ago

react-native-nj-one-click v1.3.1

Weekly downloads
28
License
MIT
Repository
github
Last release
4 months ago

react-native-nj-one-click

阿里云一键登录,支持 android 和 ios

Getting started

$ npm install react-native-nj-one-click --save

Mostly automatic installation

$ react-native link react-native-nj-one-click

Usage

import { initAuthSDKInfo, showOneKeyLogin } from 'react-native-nj-one-click';

// 弹出一键登录
      showOneKeyLogin('', this.registerUrl, this.protectUrl, '', '', '', '', [
        'oneKey_login_background',
      ]);

 static initOneKeyLogin() {
    initAuthSDKInfo(isIOS() ? IOS_ONE_KEY_LOGIN : ONE_KEY_LOGIN);
    //点击其他登录事件
    this.otherLoginListener = NativeAppEventEmitter.addListener(
      'OTHERLOGIN',
      () => {
        this.goLoginPage();
      },
    );
    //手机号 网络 卡 校验失败事件
    this.errorLoginListener = NativeAppEventEmitter.addListener(
      'ERRORLOGIN',
      (result) => {
        console.log(result);
        if(isIOS){
          if(result && result.checkBoxIsChecked=="0"){
            showToast("请勾选协议");
          }
        }
        // this.goLoginPage();
      },
    );
    //一键登录校验成功事件
    this.oneKeyLoginListener = NativeAppEventEmitter.addListener(
      'ONEKEYLOGIN',
      (result) => {
        let token = result.token;
        this.normalLogin = false;
        Api.oneKeyLogin(token)
          .then((resData) => {
            // this.normalLogin = true;
            loginHandler(resData);
            backLoginBeforePage();
          })
          .catch((error) => {
            this.normalLogin = true;
            if (error === '100013') {
              showSimpleAlert({
                title: '当前账号已在另一台设备登录',
                content:
                  '请您在【设置】-【安全设置】-【设备管理】中移除已登录的手机后再试',
                confirmTxt: '知道了',
                confirmPress: () => {
                  closeAlert();
                },
              });
            }
            // else {
            //   this.goLoginPage();
            // }
          });
      },
    );
  }

对应的文档

安卓一键登录: https://help.aliyun.com/zh/pnvs/developer-reference/the-android-client-access?spm=a2c4g.11186623.help-menu-75010.d_5_1_1_0.7b724b98CyzvLF

iOS一键登录: https://help.aliyun.com/zh/pnvs/developer-reference/the-ios-client-access?spm=a2c4g.11186623.help-menu-75010.d5_1_1_1.20ea743dzdYeBD&scm=20140722.H_2249363..OR_help-T_cn~zh-V_1

1.3.1

4 months ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.3.0

2 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.13

3 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.2.0

4 years ago

1.1.10

4 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago