GithubHelp home page GithubHelp logo

jzxchiang1 / web3auth-react-native-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from web3auth/web3auth-react-native-sdk

0.0 0.0 0.0 4.24 MB

License: MIT License

Kotlin 20.17% JavaScript 16.93% Java 20.64% TypeScript 4.90% Swift 12.67% Objective-C 17.24% Ruby 5.48% Starlark 1.97%

web3auth-react-native-sdk's Introduction

@web3auth/react-native-sdk

React Native SDK for Torus OpenLogin

Installation

npm install @web3auth/react-native-sdk

Please refer to the native SDKs for platform-specific configuration.

For iOS, the redirectUrl parameter is fixed, which is \(bundleId)://auth, and does not need to be added as a iOS Custom URL Scheme.

For Android, the redirectUrl parameter is specificable, and has to be added into the AndroidManifest.xml.

Usage

Refer to the demo app for more detailed example.

import OpenloginReactNativeSdk, {
  LoginProvider,
  OpenloginNetwork,
} from '@web3auth/react-native-sdk';

React.useEffect(() => {
  OpenloginReactNativeSdk.init({
    // Your clientId obtained from OpenLogin dashboard.
    clientId:
      'BKJ3HmEqVmMHbFeW6E-CVPmdnVrnPhdBEI82kxgBVJGtaS4XlylvAE-1gmsv_Fa1CDj-xIhvTf3Kgd6mTn8nJtw',
    // TESTNET is currently broken on iOS.
    network: OpenloginNetwork.MAINNET,
    // redirectUrl only applies for Android SDK, it is designated by iOS SDK in iOS, which is \(bundleId)://auth
    redirectUrl: 'com.example.openloginreactnativesdk://auth',
  })
    .then(result => console.log(`success: ${result}`))
    .catch(err => console.log(`error: ${err}`));
}, []);

OpenloginReactNativeSdk.login({
  provider: LoginProvider.GOOGLE,
})
  .then(result => console.log(`success: ${result.privKey}, ${result.userInfo}`))
  .catch(err => console.log(`error: ${err}`))

// For iOS, it is also possible to get the default OpenLogin login screen, which let users to choose their own providers, by not specifying a provider.
// For Android, not specifying a provider will default to Google.
OpenloginReactNativeSdk.login({})
  .then(result => console.log(`success: ${result.privKey}, ${result.userInfo}`))
  .catch(err => console.log(`error: ${err}`))

Contributing

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

This project uses yarn for package management.

License

MIT

web3auth-react-native-sdk's People

Contributors

michaellee8 avatar chaitanyapotti avatar tanujgupta avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.