Skip to content

xmartlabs/react-native-line

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7d81e62 Β· Mar 17, 2025
Dec 3, 2024
Mar 5, 2025
Feb 20, 2025
Jun 30, 2020
Mar 17, 2025
Feb 20, 2025
Feb 20, 2025
Feb 20, 2025
Jun 30, 2020
Jan 9, 2025
Jan 9, 2025
Mar 17, 2025
Feb 7, 2025
Jan 9, 2025
Mar 17, 2025
Mar 17, 2025
Jan 28, 2025
Feb 20, 2025
Jan 9, 2025
Mar 12, 2025
Mar 12, 2025
Feb 7, 2025

Repository files navigation

React Native Line

npm version PRs welcome

Line SDK wrapper for React Native πŸš€

Requirements

  • Android minSdkVersion needs to be at least version 24.
  • iOS deploymentTarget needs to be at least version 15.1.
  • LINE developer account with a channel created.

Installation

With Expo

  1. Install the JavaScript side with:

    npx expo install @xmartlabs/react-native-line
  2. Add the plugin expo-build-properties to your app.json:

    "plugins": [
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static" // This is required
          }
        }
      ],
      "@xmartlabs/react-native-line"
    ]

With react-native-cli

  1. Install library:

    npm install @xmartlabs/react-native-line
    
    # --- or ---
    
    yarn add @xmartlabs/react-native-line
  2. Link native code:

    cd ios && pod install
  3. Change your AppDelegate to match the following:

    With Swift

    import RNLine
    
    ...
    
    override func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
      return LineLogin.application(application, open: url, options: options)
    }

    With Objective-C

    #import "RNLine-Swift.h"
    
    ...
    
    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
    {
      return [LineLogin application:application open:url options:options];
    }
  4. Insert the following snippet in your Info.plist to match the LINE documentation:

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)</string>
            </array>
        </dict>
    </array>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>lineauth2</string>
    </array>

Usage

  1. Import the LineLogin module:

    import LineLogin from '@xmartlabs/react-native-line'
  2. Initialize the module with the setup method:

    useEffect(() => {
      LineLogin.setup({ channelId: 'YOUR_CHANNEL_ID' })
    }, [])
  3. Login with the login method:

    LineLogin.login()

API

Function Description
login(args?: LoginArguments): Promise<LoginResult> Starts the login flow of Line's SDK (Opens the apps if it's installed and defaults to the browser otherwise). It accepts the same argumements as the LineSDK, in an object { key: value }, defaults the same way as LineSDK too.
getCurrentAccessToken(): Promise<AccessToken> Returns the current access token for the currently logged in user.
getProfile(): Promise<UserProfile> Returns the profile of the currently logged in user.
logout(): Promise<void> Logs out the currently logged in user.
refreshToken(): Promise<AccessToken> Refreshes the access token and returns it.
verifyAccessToken(): Promise<AccessTokenVerifyResult> Verifies the access token and returns it.
getBotFriendshipStatus(): Promise<BotFriendshipStatus> Gets bot friendship status if configured.

Example

If you want to see @xmartlabs/react-native-line in action, just move into the example folder and run npm install and then npm run ios/npm run android. By seeing its source code, you will have a better understanding of the library usage.

License

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

Xmartlabs Logo

Created with ❀️ by Xmartlabs