1.1.0 • Published 6 years ago
rn-line-sdk v1.1.0
rn-line
Requirements
- React native
0.54.+. - LineSDK iOS
5.0.0and Android5.0.1.
Getting started
$ npm install rn-line --save
$ yarn add rn-line
Mostly automatic installation
$ react-native link rn-line
Manual installation
iOS
First Step follow all the configuration steps in https://developers.line.biz/en/docs/ios-sdk/swift/setting-up-project/
$ pod install
- In XCode, in the project navigator, right click
Libraries➜Add Files to [your project's name] - Go to
node_modules➜rn-lineand addRNline.xcodeproj - In XCode, in the project navigator, select your project. Add
libRNLine.ato your project'sBuild Phases➜Link Binary With Libraries - Run your project (
Cmd+R)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.grapesgreenslab.rnline.RNLinePackage;to the imports at the top of the file - Add
new RNLinePackage()to the list returned by thegetPackages()method
- Append the following lines to
android/settings.gradle:include ':rn-line' project(':rn-line').projectDir = new File(rootProject.projectDir, '../node_modules/rn-line/android') - Insert the following lines inside the dependencies block in
android/app/build.gradle:compile project(':rn-line') - 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>Usage
import LineSDK from 'rn-line';Login
LineSDK.login(permission: Array, botPrompt: String);Example
_login = async () => {
try {
const resIn = await LineSDK.login(['PROFILE'], 'aggressive');
console.log(resIn);
} catch (e) {
console.log(e)
}
};Logout
LineSDK.logout();Example
_logout = async () => {
try {
const resOut = await LineSDK.logout();
console.log(resOut);
} catch (e) {
console.log(e);
console.log({ ...e });
}
};Get Profile
LineSDK.getUserProfile();Example
_getProfile = async () => {
try {
const resOut = await LineSDK.getUserProfile();
console.log(resOut);
} catch (e) {
console.log(e);
console.log({ ...e });
}
};Get AccessToken
LineSDK.getAccessToken();Example
_getAccessToken = async () => {
try {
const resOut = await LineSDK.getAccessToken();
console.log(resOut);
} catch (e) {
console.log(e);
console.log({ ...e });
}
};Get FriendshipStatus
LineSDK.getFriendshipStatus()_getFriendshipStatus = async () => {
try {
const resOut = await LineSDK.getFriendshipStatus();
console.log(resOut);
} catch (e) {
console.log(e);
console.log({ ...e });
}
};