LINE SDK v4.1 for iOS Objective-C reference

Classes

ClassLineSDKAPI

Utility class for calling the Social API.

Superclass NSObject
Declared in LineSDKAPI.h

Methods

initWithConfiguration
- (instancetype)initWithConfiguration:(LineSDKConfiguration *)configuration NS_DESIGNATED_INITIALIZER;

Initializes the LineSDKAPI object using the LineSDKConfiguration object.

currentAccessToken
- (nullable LineSDKAccessToken *)currentAccessToken;

Gets the access token that the SDK is using for the user.

Return value

The LineSDKAccessToken object which contains the access token. nil if no access token is available.

getProfileWithCallbackQueue:completion
- (void)getProfileWithCallbackQueue:(dispatch_queue_t)queue completion:(LineSDKAPIGetProfileCompletion)completion NS_SWIFT_NAME(getProfile(queue:completion:));

Gets the user's profile information. To specify a dispatch queue where the completion block is to be executed, pass the desired queue into the queue parameter.

Parameters
Parameter Description
queue The queue where the completion block is executed. If nil, the completion block is executed in the main queue.
completion The completion block called when the user's profile information is returned.
Completion block arguments
Argument Description
profile The user's profile information.
error The error returned by the API call. nil if the API call is successful.
getProfileWithCompletion
- (void)getProfileWithCompletion:(void(^)(LineSDKProfile * _Nullable profile, NSError * _Nullable error))completion NS_SWIFT_NAME(getProfile(completion:));

Gets the user's profile information. The completion block is executed in the main queue.

Parameters
Parameter Description
completion The completion block called when the user's profile information is returned.
Completion block arguments
Argument Description
profile The user's profile information.
error The error returned by the API call. nil if the API call is successful.
logoutWithCallbackQueue:completion
- (void)logoutWithCallbackQueue:(dispatch_queue_t)queue completion:(LineSDKAPILogoutCompletion)completion NS_SWIFT_NAME(logout(queue:completion:));

Revokes the access token. To specify a dispatch queue where the completion block is to be executed, pass the desired queue into the queue parameter.

Parameters
Parameter Description
queue The queue where the completion block is executed. If nil, the completion block is executed in the main queue.
completion The completion block called when the logout is completed.
Completion block arguments
Argument Description
success YES if the logout succeeds; NO otherwise.
error The error returned by the API call. nil if the API call is successful.
logoutWithCompletion
- (void)logoutWithCompletion:(void(^)(BOOL success, NSError * _Nullable error))completion;

Revokes the access token. The completion block is executed in the main queue.

Parameters
Parameter Description
completion The completion block called when the logout is complete.
Completion block arguments
Argument Description
success YES if the logout succeeds; NO otherwise.
error The error returned by the API call. nil if the API call is successful.
refreshTokenWithCallbackQueue:completion
- (void)refreshTokenWithCallbackQueue:(dispatch_queue_t)queue completion:(LineSDKAPITokenRefreshCompletion)completion NS_SWIFT_NAME(refreshToken(queue:completion:));

Refreshes the access token that the SDK is using for the user. To specify a dispatch queue where the completion block is to be executed, pass the desired queue into the queue parameter.

Parameters
Parameter Description
queue The queue where the completion block is executed. If nil, the completion block is executed in the main queue.
completion The completion block called when the access token is refreshed.
Completion block arguments
Argument Description
accessToken The refreshed access token.
error The error returned by the API call. nil if the API call is successful.
refreshTokenWithCompletion
- (void)refreshTokenWithCompletion:(void(^)(LineSDKAccessToken * _Nullable accessToken, NSError * _Nullable error))completion;

Refreshes the access token that the SDK is using. The completion block is executed in the main queue.

Parameters
Parameter Description
completion The completion block called when the access token is refreshed.
Completion block arguments
Argument Description
accessToken The refreshed access token.
error The error returned by the API call. nil if the API call is successful.
verifyTokenWithCallbackQueue:Completion
- (void)verifyTokenWithCallbackQueue:(dispatch_queue_t)queue completion:(LineSDKAPIVerifyTokenCompletion)completion NS_SWIFT_NAME(verifyToken(queue:completion));

Checks whether the access token that the SDK is using for the user is valid or not. To specify a dispatch queue where the completion block is to be executed, pass the desired queue into the queue parameter.

Parameters
Parameter Description
queue The queue where the completion block is executed. If nil, the completion block is executed in the main queue.
completion The completion block called when the user's token is verified.
Completion block arguments
Argument Description
result The result of the verify call.
error The error returned by the API call. nil if the API call is successful.
verifyTokenWithCompletion
- (void)verifyTokenWithCompletion:(void(^)(LineSDKVerifyResult * _Nullable result, NSError * _Nullable error))completion;

Checks whether the access token that the SDK is using for the user is valid or not. The completion block is executed in the main queue.

Parameters
Parameter Description
completion The completion block called when the access token is verified.
Completion block arguments
Argument Description
result The result of the verify call.
error The error returned by the API call. nil if the API call is successful.

ClassLineSDKAccessToken

Represents an access token that is used to call the Social API.

Superclass NSObject
Declared in LineSDKAccessToken.h

Properties

accessToken
@property (nonatomic, copy, readonly) NSString *accessToken;

The access token.

expiresIn
@property (nonatomic, readonly) NSTimeInterval expiresIn;

The amount of time in seconds until the access token expires.

Methods

estimatedExpiredDate
- (NSDate *)estimatedExpiredDate;

Gets the estimated time in UNIX time when the access token expires. The expiration time that is returned by this method is not exact because it is calculated using time values that are cached on the client.

Return value

The estimated time in UNIX time of when the access token expires.

ClassLineSDKCredential

Represents credentials that are used to grant access to the Social API.

Superclass NSObject
Declared in LineSDKAPI.h

Properties

accessToken
@property (nonatomic, strong, readonly, nullable) LineSDKAccessToken *accessToken;

The access token.

permissions
@property (nonatomic, strong, readonly) NSOrderedSet<NSString *> *permissions;

The set of permissions that the access token holds. The following is a list of the permission codes.

Permission code Description
P The token can be used to get the user’s profile information.

ClassLineSDKLogin

Provides methods that are used to perform LINE login.

Superclass NSObject
Declared in LineSDKLogin.h
Protocols LineSDKLoginDelegate

Properties

configuration
@property (nonatomic, strong, readonly) LineSDKConfiguration *configuration;

Contains various LINE SDK configuration values such as the Channel ID and the access token.

Methods

canLoginWithLineApp
- (BOOL)canLoginWithLineApp;

Checks whether it is possible to log in using LINE.

Return value

YES if it is possible to log in using LINE; NO otherwise. If NO, LINE is not installed on the device.

handleOpenURL
- (BOOL)handleOpenURL:(NSURL *)aURL;

Handles the return data from LINE during app-to-app authentication. You must call the handleOpenUrl method in your application's openURL method as in the following example.

openURL example
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [[LineSDKLogin sharedInstance] handleOpenURL:url];
}
Parameters
Parameter Description
aURL The URL that LINE passes to the openURL method during app-to-app authentication. You don't need to set the value explicitly.
Return value

YES if the URL is successfully handled by the SDK; NO otherwise.

installLineApp
- (void)installLineApp;

Transitions to the app store to install LINE.

isAuthorized
- (BOOL)isAuthorized;

Checks whether the user is logged in and has a access token.

Return value

YES if the SDK has a access token for the user. This signifies that the user is logged in. NO otherwise.

isAuthorizing
- (BOOL)isAuthorizing;

Checks whether login is in progress.

Return value

YES if login is in progress; NO otherwise.

sharedInstance
+ (instancetype)sharedInstance;

Gets the singleton instance of the LineSDKLogin class.

startLogin
- (void)startLogin;

Begins the login process. If LINE is installed, the SDK defaults to using app-to-app authentication. If it is not installed, the SDK logs in using a Safari View Controller.

startWebLogin
- (void)startWebLogin;

Begins the login process. This function uses a Safari View Controller to log in, not app-to-app authentication.

ClassLineSDKConfiguration

Contains the settings that are needed to initialize the SDK.

Superclass NSObject
Declared in LineSDKConfiguration.h

Properties

channelID
@property (nonatomic, strong, readonly) NSString *channelID;

The Channel ID that the application is configured to use. This value is read from the LineSDKConfig section in the application's Info.plist.

Methods

currentAccessToken
- (nullable LineSDKAccessToken *)currentAccessToken;

Gets the access token that is stored by the SDK.

ClassLineSDKProfile

Represents a user's LINE profile in the Social API.

Superclass NSObject
Declared in LineSDKProfile.h

Properties

displayName
@property (nonatomic, copy, readonly) NSString *displayName;

The user’s display name.

pictureURL
@property (nonatomic, copy, readonly, nullable) NSURL *pictureURL;

The user’s profile media URL.

statusMessage
@property (nonatomic, copy, readonly, nullable) NSString *statusMessage;

The user’s status message.

userId
@property (nonatomic, copy, readonly) NSString *userID;

The user's user ID.

ClassLineSDKVerifyResult

Describes the result of an attempt to verify the access token.

Superclass NSObject
Declared in LineSDKVerifyResult.h

Properties

channelID

@property (nonatomic, copy, readonly) NSString *channelID;

The Channel ID that is used by the application.

expiresIn

@property (nonatomic, readonly) NSTimeInterval expiresIn;

The amount of time in milliseconds until the access token expires.

permissions

@property (nonatomic, copy, readonly, nullable) NSOrderedSet<NSString *> *permissions;

The set of permissions that the access token holds. The following is a list of the permission codes.

Permission code Description
P The token can be used to get the user’s profile information.

Protocols

ProtocolLineSDKLoginDelegate

Defines the methods used to receive event notifications from the LineSDKLogin object.

Extends protocol NSObject
Declared in LineSDKLogin.h

Methods

didLogin
- (void)didLogin:(LineSDKLogin *)login
credential:(nullable LineSDKCredential *)credential
profile:(nullable LineSDKProfile *)profile
error:(nullable NSError *)error;

Receives the login result.

Parameters
Parameter Description
login The LineSDKLogin object that is used to make the login request.
credential The credentials granted by the login request.
profile The profile information of the user.
error The information about the failure if the login request fails. nil if the login request is successful.