# Using universal links
You can improve the security of your app with Apple's universal links (opens new window) feature that securely communicates information between apps. If you set up a universal link, LINE tries to open your app with the universal link first. If the universal link is invalid, LINE falls back to a URL based on your iOS bundle ID (see Linking your app to your channel.
Although universal links are optional, we recommend using them to make your app more secure.
To enable users to open your app with a universal link, follow these steps:
- Create an association between your app and your server.
- Set up a universal link on the LINE Developers Console.
- Set up the universal link in the
Info.plist
file. - Handle the login result after your app is opened by the universal link.
# 1. Create an association between your app and your server
For this step, see Allowing Apps and Websites to Link to Your Content (opens new window) by Apple.
Complete these tasks:
- Create an
apple-app-site-association
file that contains JSON data about the URLs that your app can handle and put it in your HTTPS server. - Add an Associated Domains entitlement to your app.
This section assumes that you use https://yourdomain.com/line-auth/
as the universal link to handle a LINE authorization response.
Include /line-auth/*
in the paths
field of your apple-app-site-association
file. An example of a valid Apple App Site Association file looks like below:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "YOUR_TEAM_ID.com.yourcompany.yourapp",
"paths": [ "/line-auth/*" ]
}
]
}
}
Note that you can test universal links only on a real iOS device. You need to set up your app ID and profile correctly. If your universal links don’t work, see Troubleshooting Universal Links (opens new window) on Apple's developer site. Ensure that your universal links work before you proceed with the next steps.
# 2. Set up a universal link on the LINE Developers Console
For the procedure, see Linking your app to your channel. In this example, we set it to https://yourdomain.com/line-auth/
.
# 3. Set up the universal link in the Info.plist
file
In your app's Info.plist
file, add a UniversalLink
key and set it to the value you want in the LineSDKConfig
dictionary as below. It should be at the same level as your ChannelID
key.
<key>LineSDKConfig</key>
<dict>
<key>ChannelID</key>
<string>1234567890</string>
<key>UniversalLink</key>
<string>https://yourdomain.com/line-auth/</string>
</dict>
# 4. Handle the login result after your app is opened by the universal link
Add the code below in the AppDelegate
file.
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
{
if ([[LineSDKLogin sharedInstance] handleOpenURL:userActivity.webpageURL]) {
return YES;
}
// Your other code to handle universal links and/or user activities.
}
Now LINE can open your app with the universal link and your app can handle the login result.