yoonjaepark / flutter_naver_login

A Flutter plugin for Naver Sign In.
BSD 2-Clause "Simplified" License
46 stars 69 forks source link

iOS에서 로그인 도중 취소했을 때 logIn() 반환되지 않음 #76

Open nicejhkim opened 1 year ago

nicejhkim commented 1 year ago

iOS 16, flutter_naver_login 1.7.0 (1.6.0 에서도 같은 현상 발생)

FlutterNaverLogin.loginIn(); 호출했을 때 사용자가 취소하면 해당 함수가 반환되지 않고 멈춰버립니다.

final naverLoginResult = await FlutterNaverLogin.logIn();

안드로이드에서는 같은 경우에 정상적으로 user_cancel이 반환되는데, iOS에서는 결과가 반환되지 않고 exception도 발생하지 않습니다.

JaeHeee commented 1 year ago

AppDelegate.swift 파일에 아래 코드를 추가해서 임시로 사용하실 수 있을것 같습니다.

import UIKit
import Flutter
import NaverThirdPartyLogin

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)

    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }

    override func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
       if (url.absoluteString.contains("thirdPartyLoginResult")) {
        var naverLoginUrl = url;
        if !url.absoluteString.contains("authCode") {
            let redundantCodeLength = 2;
            naverLoginUrl = URL(string: "\(url.absoluteString.dropLast(redundantCodeLength))0&authCode=")!;
        }
        return NaverThirdPartyLoginConnection.getSharedInstance().application(app, open: naverLoginUrl, options: options)
    }
    }
}
byungjuJin commented 1 year ago

+1