LoginManager
public class LoginManager
Represents a login manager. You can set up the LINE SDK configuration, log in and log out the user with the LINE authorization flow, and check the authorization status.
-
The shared instance of the login manager. Always use this instance to interact with the login process of the LINE SDK.
Declaration
Swift
public static let shared: LoginManager -
The current login process. A non-
nilvalue indicates that there is an ongoing process and the LINE SDK is waiting for the login result;nilotherwise.Declaration
Swift
public private(set) var currentProcess: LoginProcess? { get } -
Checks and returns whether the current
LoginManagerinstance is ready to use. Call thesetupmethod to set up the LINE SDK with basic information before you call any other methods or properties in the LINE SDK.Declaration
Swift
public var isSetupFinished: Bool { get } -
Checks and returns whether the user was authorized and an access token exists locally. This method does not check whether the access token has been expired. To verify an access token, use the
API.Auth.verifyAccessTokenmethod.Declaration
Swift
public var isAuthorized: Bool { get } -
Checks and returns whether the authorizing process is currently ongoing.
Declaration
Swift
public var isAuthorizing: Bool { get } -
Sets up the current
LoginManagerinstance.Note
Call this method before you access any other methods or properties in the LINE SDK. Call this method only once because the login manager cannot be set up multiple times.We strongly suggest that you specify a valid universal link URL. Set up your own universal link callback for your channel by following the guide on the LINE Developers site. When the callback is set properly, LINE will try to bring up your app with the universal link first, which improves the security of the authorization flow and protects your data. If the
universalLinkURLparameter isnil, only a custom URL scheme will be used to open your app after the authorization in LINE is complete.Declaration
Swift
public func setup(channelID: String, universalLinkURL: URL?)Parameters
channelIDThe channel ID for your app.
universalLinkURLThe universal link used to navigate back to your app from LINE.
-
Logs in to the LINE Platform.
Note
Only one process can be started at a time. Do not call this method again to start a new login process before
completionis invoked.If the value of
permissionscontains.profile, the user profile will be retrieved during the login process and contained in theuserProfileproperty of theLoginResultobject incompletion. Otherwise, theuserProfileproperty will benil. Use this profile to identify your user. For more information, seeUserProfile.An access token will be issued if the user authorizes your app. This token and a refresh token will be automatically stored in the keychain of your app for later use. You do not need to refresh the access token manually because any API call will attempt to refresh the access token if necessary. However, if you need to refresh the access token manually, use the
API.Auth.refreshAccessToken(with:)method.Declaration
Swift
@discardableResult public func login( permissions: Set<LoginPermission> = [.profile], in viewController: UIViewController? = nil, parameters: LoginManager.Parameters = .init(), completionHandler completion: @escaping (Result<LoginResult, LineSDKError>) -> Void ) -> LoginProcess?Parameters
permissionsThe set of permissions requested by your app. The default value is
[.profile].viewControllerThe the view controller that presents the login view controller. If
nil, the topmost view controller in the current view controller hierarchy will be used.parametersThe parameters used during the login process. For more information, see
LoginManager.Parameters.completionThe completion closure to be invoked when the login action is finished.
Return Value
The
LoginProcessobject which indicates that this method has started the login process. -
Logs out the current user by revoking the refresh token and all its corresponding access tokens.
Declaration
Swift
public func logout(completionHandler completion: @escaping (Result<(), LineSDKError>) -> Void)Parameters
completionThe completion closure to be invoked when the logout action is finished.
-
Asks this
LoginManagerobject to handle a URL callback from either LINE or the web login flow.Note
This method has the same method signature as in the methods of theUIApplicationDelegateprotocol. Pass all arguments to this method without any modification.Declaration
Swift
public func application( _ app: UIApplication, open url: URL?, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> BoolParameters
appThe singleton app object.
urlThe URL resource to open. This resource should be the one passed from the iOS system through the related method of the
UIApplicationDelegateprotocol.optionsA dictionary of the URL handling options passed from the related method of the
UIApplicationDelegateprotocol.Return Value
trueifurlhas been successfully handled;falseotherwise.
-
Sets the preferred language used when logging in with the web authorization flow.
If not set, the web authentication flow shows the login page in the user’s device language, or falls back to English. Once set, the web page will be displayed in the preferred language.
Note
This property does not affect the preferred language when LINE is used for authorization. LINE and the login screen are always displayed in the user’s device language.Declaration
Swift
@available(*, deprecated, message: "Set the preferred language in a `LoginManager.Parameters` value and use\n`login(permissions:in:parameters:completionHandler:﹚` instead.\"﹚") public var preferredWebPageLanguage: WebPageLanguage? -
Logs in to the LINE Platform.
Note
Only one process can be started at a time. Do not call this method again to start a new login process before
completionis invoked.If the value of
permissionsis.profile, the user profile will be retrieved during the login process and contained in theuserProfileproperty of theLoginResultobject incompletion. Otherwise, theuserProfileproperty will benil. Use this profile to identify your user. For more information, seeUserProfile.An access token will be issued if the user authorizes your app. This token and a refresh token will be automatically stored in the keychain of your app for later use. You do not need to refresh the access token manually because any API call will attempt to refresh the access token if necessary. However, if you need to refresh the access token manually, use the
API.Auth.refreshAccessToken(with:)method.Declaration
Swift
@available(*, deprecated, message: "Convert the `options` to a `LoginManager.Parameters` value and\nuse `login(permissions:in:parameters:completionHandler:﹚` instead.\"﹚") @discardableResult public func login( permissions: Set<LoginPermission> = [.profile], in viewController: UIViewController? = nil, options: LoginManagerOptions, completionHandler completion: @escaping (Result<LoginResult, LineSDKError>) -> Void) -> LoginProcess?Parameters
permissionsThe set of permissions requested by your app. The default value is
[.profile].viewControllerThe the view controller that presents the login view controller. If
nil, the topmost view controller in the current view controller hierarchy will be used.optionsThe options used during the login process. For more information, see
LoginManagerOptions.completionThe completion closure to be invoked when the login action is finished.
Return Value
The
LoginProcessobject which indicates that this method has started the login process. -
Parameters used during login.
See moreDeclaration
Swift
public struct Parameters -
The style for showing the “Add LINE Official Account as friend” prompt on the consent screen.
See moreDeclaration
Swift
public enum BotPrompt : String -
Represents the language used in the web page.
See moreDeclaration
Swift
public struct WebPageLanguage
View on GitHub
LoginManager Class Reference