|  | 
| 1 |  | -# WIP | 
| 2 |  | -## React native LINE | 
|  | 1 | +# React native LINE | 
|  | 2 | +iOS and Android Native wrapper for Line's MobileSDK. | 
|  | 3 | + | 
|  | 4 | +## Requirements | 
|  | 5 | +- React native `0.48.+`. | 
|  | 6 | +- LineSDK iOS `4.0.3` and Android `4.0.6`. | 
|  | 7 | + | 
|  | 8 | +## Installation | 
|  | 9 | +First, install the npm package and link it to your Android and iOS projects with react-native link. | 
|  | 10 | +```bash | 
|  | 11 | +  npm install react-native-line | 
|  | 12 | +  react-native link react-native-line | 
|  | 13 | +``` | 
|  | 14 | +### iOS Setup | 
|  | 15 | +Follow all the configuration steps in [Line's iOS integration guide](https://developers.line.me/en/docs/line-login/ios/integrate-line-login/) | 
|  | 16 | + | 
|  | 17 | +### Android Setup | 
|  | 18 | +1. Follow all the configuration steps in [Line's Android integration guide](https://developers.line.me/en/docs/line-login/android/integrate-line-login/) | 
|  | 19 | +2. Add the string `line_channel_id` to your strings file with the the channel id that you have on your line console. | 
|  | 20 | +```xml | 
|  | 21 | +<string name="line_channel_id" translatable="false">Your channel id here</string> | 
|  | 22 | +``` | 
|  | 23 | +3. Download the line Android SDK [here](https://developers.line.me/en/docs/line-login/downloads/) and save it on a new folder named `libs` under your `app` folder on your android project. | 
|  | 24 | +4. Add the following to your app's build.gradle: | 
|  | 25 | +```gradle | 
|  | 26 | +repositories { | 
|  | 27 | +    flatDir { | 
|  | 28 | +        dirs 'libs' | 
|  | 29 | +    } | 
|  | 30 | +} | 
|  | 31 | +``` | 
|  | 32 | + | 
|  | 33 | +## Usage | 
|  | 34 | +First, require the `LineLogin` module: | 
|  | 35 | +```javascript | 
|  | 36 | +import LineLogin from 'react-native-line' | 
|  | 37 | +``` | 
|  | 38 | +Then, you can start using all the functions that are available: | 
|  | 39 | + | 
|  | 40 | +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.)` | 
|  | 41 | + | 
|  | 42 | +2. `loginWithPermissions = (permissions) => Promise<{Profile, AccessToken}>`: **iOS ONLY** Works as the `login` function but you can provide custom permissions settings. | 
|  | 43 | + | 
|  | 44 | +3. `currentAccessToken = () => Promise<AccessToken>`: Returns the current access token for the currently logged in user. | 
|  | 45 | + | 
|  | 46 | +4. `getUserProfile = () => Promise<Profile>`: Returns the profile of the currently logged in user. | 
|  | 47 | + | 
|  | 48 | +5. `logout = () => Promise<Void>`: Logs out the currently logged in user. | 
|  | 49 | + | 
|  | 50 | +Example: | 
|  | 51 | +```javascript | 
|  | 52 | +  LineLogin.login() | 
|  | 53 | +    .then((user) => { | 
|  | 54 | +      console.log(user.profile.displayName) | 
|  | 55 | +    }) | 
|  | 56 | +    .catch((err) => { | 
|  | 57 | +      console.log(err) | 
|  | 58 | +    }) | 
|  | 59 | +``` | 
|  | 60 | + | 
|  | 61 | +### Return values | 
|  | 62 | +The following objects are returned on the methods described above: | 
|  | 63 | +1. Profile: | 
|  | 64 | +```typescript | 
|  | 65 | +{ | 
|  | 66 | +  displayName: String, | 
|  | 67 | +  userID: String, | 
|  | 68 | +  statusMessage: String, | 
|  | 69 | +  pictureURL: String?, | 
|  | 70 | +} | 
|  | 71 | +``` | 
|  | 72 | +2. AccessToken: | 
|  | 73 | +```typescript | 
|  | 74 | +{ | 
|  | 75 | +  accessToken: String, | 
|  | 76 | +  expirationDate: String, | 
|  | 77 | +} | 
|  | 78 | +``` | 
|  | 79 | +
 | 
|  | 80 | +## Example | 
|  | 81 | +To see more of `react-native-line` in action you can check out the source in the `example` folder. | 
|  | 82 | +
 | 
|  | 83 | +## Authors | 
|  | 84 | +- [Santiago Fernandez](https://github.com/santiagofm) | 
|  | 85 | +- [Mauricio Cousillas](https://github.com/mcousillas6) | 
|  | 86 | +
 | 
|  | 87 | +## License | 
|  | 88 | +`react-native-line` is available under the MIT license. See the LICENCE file for more info. | 
0 commit comments