Giter Site home page Giter Site logo

react-native-line's Introduction

React native LINE

iOS and Android Native wrapper for Line's MobileSDK.

Requirements

  • React native 0.48.+.
  • LineSDK iOS 4.1.0 and Android 4.0.8.

Installation

First, install the npm package and link it to your Android and iOS projects with react-native link.

  npm install react-native-line-sdk
  react-native link react-native-line-sdk

iOS Setup

Follow all the configuration steps in Line's iOS integration guide

Android Setup

  1. Follow all the configuration steps in Line's Android integration guide
  2. Add the string line_channel_id to your strings file with the the channel id that you have on your line console.
<string name="line_channel_id" translatable="false">Your channel id here</string>
  1. Download the line Android SDK here and save it on a new folder named libs under your app folder on your android project.
  2. Add the following to your app's build.gradle:
repositories {
    flatDir {
        dirs 'libs'
    }
}

Usage

First, require the LineLogin module:

import LineLogin from 'react-native-line-sdk'

Then, you can start using all the functions that are available:

  1. login = () => Promise<{Profile, AccessToken}>: Starts the login flow of Line's SDK (Opens the apps if it's installed and defaults to the browser otherwise.)`

  2. loginWithPermissions = (permissions) => Promise<{Profile, AccessToken}>: iOS ONLY Works as the login function but you can provide custom permissions settings.

  3. currentAccessToken = () => Promise<AccessToken>: Returns the current access token for the currently logged in user.

  4. getUserProfile = () => Promise<Profile>: Returns the profile of the currently logged in user.

  5. logout = () => Promise<Void>: Logs out the currently logged in user.

Example:

  LineLogin.login()
    .then((user) => {
      console.log(user.profile.displayName)
    })
    .catch((err) => {
      console.log(err)
    })

Return values

The following objects are returned on the methods described above:

  1. Profile:
{
  displayName: String,
  userID: String,
  statusMessage: String,
  pictureURL: String?,
}
  1. AccessToken:
{
  accessToken: String,
  expirationDate: String,
}

Example

To see more of react-native-line-sdk in action you can check out the source in the example folder.

Authors

License

react-native-line-sdk is available under the MIT license. See the LICENCE file for more info.

react-native-line's People

Contributors

mcousillas6 avatar toshi3221 avatar santiagofm avatar

Watchers

James Cloos avatar  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.