라인 연동
- 인쇄
- PDF
라인 연동
- 인쇄
- PDF
기사 요약
이 요약이 도움이 되었나요?
의견을 보내 주셔서 감사합니다.
Classic/VPC 환경에서 이용 가능합니다.
라인 로그인 기능을 사용하기 위한 사용 가이드입니다.
라인에 대한 설명은 Line Developers를 참조해 주십시오.
iOS
Info.plist 설정
- 프로젝트의 TARGETS > Info > URL Types 에서 "line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)" 를 추가해 주십시오.
- 프로젝트의 TARGETS > Info > Custom iOS Target Properties > 'Queried URL Schemes' 에 'lineauth2' 를 추가해 주십시오.
Info.plist 에 직접 추가는 경우의 예시는 아래와 같습니다.
Key | Value |
---|---|
CFBundleURLSchemes | line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER) |
LSApplicationQueriesSchemes | lineauth2 |
// Info.plist
<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>
Swift
다음 코드를 사용하여 AppDelegate.swift 메서드의 코드를 대체해 주십시오.
// AppDelegate.swift
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
ApplicationDelegate.shared.application(
application,
didFinishLaunchingWithOptions: launchOptions
)
}
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
let sceneConfiguration = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
sceneConfiguration.delegateClass = SceneDelegate.self
return sceneConfiguration
}
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
...
// 라인 로그인 콜백
NotificationCenter.default.post(name: Notification.Name("LineLoginURL"), object: nil, userInfo: ["application": application, "url": url, "options": options, "type": "AppDelegate"])
...
return true
}
}
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
guard let url = URLContexts.first?.url else {
return
}
...
// 라인 로그인 콜백
NotificationCenter.default.post(name: Notification.Name("LineLoginURL"), object: nil, userInfo: ["url": url, "type": "SceneDelegate"])
...
}
Objective-C
다음 코드를 사용하여 AppDelegate.m 메서드의 코드를 대체 및 추가해 주십시오.
// AppDelegate.m
#import "AppDelegate.h"
@interface AppDelegate () <UNUserNotificationCenterDelegate>
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions {
...
return YES;
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
...
// 라인 로그인 콜백
NSDictionary *userInfo = @{@"application": app, @"url": url, @"options": options, @"type": @"AppDelegate"};
[[NSNotificationCenter defaultCenter] postNotificationName:@"LineLoginURL" object:nil userInfo:userInfo];
...
return YES;
}
다음 코드를 사용하여 SceneDelegate.m 메서드의 코드를 대체 및 추가해 주십시오.
// SceneDelegate.m
#import "SceneDelegate.h"
@interface SceneDelegate ()
@end
@implementation SceneDelegate
- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
NSURL *url = URLContexts.allObjects.firstObject.URL;
if (!url) return;
// LINE 로그인 콜백
NSDictionary *userInfo = @{@"url": url, @"type": @"SceneDelegate"};
[[NSNotificationCenter defaultCenter] postNotificationName:@"LineLoginURL" object:nil userInfo:userInfo];
}
이 문서가 도움이 되었습니까?