Login iOS apps with LINE

Tram Ho

Introduce

Shortening the registration process to increase the user experience is a common trend of today’s applications. The use of SNS platforms for authentication has become popular and supported by many platforms such as Facebook, Line, Twitter, Apple, …

In today’s article, I will guide the steps to add the LINE authentication feature in the iOS project

Configure LINE

Step 1: Access Link developers.line.biz and log in with your LINE account

You can use your personal LINE account or sign up for a LINE Business account for your app

Step 2: Create a Provider Provider that can be an individual, a company or an organization that provides translation through the LINE platform. Here I will create a provider named DemoLogin

Interface after creating and choosing Provider

In the Provider there are some Settings, but for this example we will not need to pay attention

Step 3: Create and configure Channel Channel to be the communication channel between the methods provided by the LINE Platform and the Provider service.

Select “Create a LINE Login Channel”

I will create a Channel named DemoLoginApp, choose App types as “Mobile App” and add a description for the Channel (Required)

.

Note when creating a Channel name not include the word “LINE”

This is the interface after creating the Channel

Here you need to pay attention to Channel ID. We will use this to configure the App

Switch to the LINE Login tab and enter BundleID of the App into the iOS bundle ID. BundleID of the App you can find in the General Settings of the project in XCode

The iOS universal link field can be left blank as an optional. LINE encourages you to use Universal Link to increase the security of communication between LINE and the application. In this example, I will only use bundle ID to connect to the App

Configure application

Step 1: Add LINE SDK into Project. I will use Cocoapods in this demo

In addition LINE also supports other methods to add SDK to Project. Everyone can refer to https://developers.line.biz/en/docs/ios-sdk/swift/setting-up-project/#installation

Step 2: Open the Info.plist file as Source Code and add this code before the final </dict> tag

Step 3: Configure LINE SDK in App Delegate and Scence Delegate In this step we will use the Channel ID we mentioned above.

import LineSDK and add the command as shown in the picture to set up, replace “YOUR_CHANNEL_ID” with the id of the Channel just created.
LINE encourages us to use the universal link to open the App after completing Login. This way is more secure than opening the App directly from a registered Bundle ID. Setting up universal link requires a server and domain as well as setup is quite complex, so in this example I will not use it. Therefore the universalLinkURL field will set nil

To handle the response returned from LINE, we need to add the following method in AppDelegate

With iOS 13 and above, the return URL will be invoked by UISceneDelegate. Therefore we need to add the following code in Scene Delegate

Step 4: Create an interface
My interface will create a Button. We can use the LINE object provided by LoginButton and implement LoginButtonDelegate for the controller to get the data reponse.

Alternatively we can create the button as usual and call the login function with code

Add the following code

Run Project and we will get the results

Response returned

Refer

https://developers.line.biz/en/

Source Code Demo

https://github.com/buixuanhuy5798/DemoLoginLine

Share the news now

Source : Viblo