如何处理 PianoID SDK iOS 的重定向 URL?

How to handle the redirect URLs for the PianoID SDK iOS?

提问人:Oussama Ridéne 提问时间:1/17/2023 最后编辑:Oussama Ridéne 更新时间:1/18/2023 访问量:55

问:

当我尝试在我的 iOS 应用程序中连接到 Facebook 时,该应用程序将我重定向到 Facebook 应用程序,然后在两个应用程序之间出现循环,这意味着用户在两个应用程序之间来回发送,而无法完成登录过程。我怀疑我的代码中缺少某些内容来正确处理 PianoID SDK 的重定向 URL,我想知道需要做些什么来解决此问题。

这是我的appDelegate类:

@objc class AppDelegate: FlutterAppDelegate, PianoIDDelegate {
    private var flutterResult: FlutterResult? = nil
    @Published private(set) var initialized = false
    @Published private(set) var token: PianoIDToken?
    var cookiessseion = ""
    var startdate = ""
    var enddate = ""
    var pianoToken=""
    
    
        func pianoID(_ pianoID: PianoOAuth.PianoID, didSignInForToken token: PianoOAuth.PianoIDToken!, withError error: Error!) {}
        func pianoID(_ pianoID: PianoOAuth.PianoID, didSignOutWithError error: Error!) {}
        func pianoIDSignInDidCancel(_ pianoID: PianoOAuth.PianoID) {}

    override func application(_ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        PianoID.shared.endpointUrl = Settings.endpoint.api
                PianoID.shared.aid = Settings.aid
                PianoID.shared.isSandbox = true
                PianoID.shared.signUpEnabled = true
        PianoID.shared.googleClientId = Settings.clientId
                PianoID.shared.delegate = self
        PianoOAuth.PianoIDApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
        GeneratedPluginRegistrant.register(with: self)
        let name = Bundle.main.infoDictionary?["CFBundleName"]
        let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"]
        GEMConfig.sharedInstance().setAppInfo(name as? String, version: version as? String)
        //FirebaseApp.configure()
        guard let controller = window?.rootViewController as? FlutterViewController else {
              fatalError("rootViewController is not type FlutterViewController")
            }
        let Channel = FlutterMethodChannel(name: "flutter.native/helper", binaryMessenger: controller.binaryMessenger)
        Channel.setMethodCallHandler({
            [weak self] (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
                if(call.method == "testpiano"){
                        self?.initPianoID()
                        self?.flutterResult = result
            } else {
                result(FlutterMethodNotImplemented)
            }
        })
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
    /// Sign In callback
           func signIn(result: PianoIDSignInResult!, withError error: Error!) {
               if let r = result {
                   token = r.token
                   do {
                       let PianoIDTokenString = try JSONParserSwift.getJSON(object: token)
                       self.flutterResult?(PianoIDTokenString)
                   } catch {
                       print("Unexpected data error: \(error)")
                   }
               } else {
               }
           }
           /// Sign Out callback
           func signOut(withError error: Error!) {
               token = nil
           }
           /// Cancel callback
           func cancel() {
           }
    private func initPianoID() {
       PianoID.shared.signIn()
     }
    func openSettings(alert: UIAlertAction!) {
        if let url = URL.init(string: UIApplication.openSettingsURLString) {
            UIApplication.shared.open(url, options: [:], completionHandler: nil)
        }
    }
    override public func applicationDidBecomeActive(_ application: UIApplication) {
        debugPrint("applicationDidBecomeActive")
        if #available(iOS 14, *) {
            DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
                ATTrackingManager.requestTrackingAuthorization { status in
                }
            }
        }
    }
}
extension Date {
    func currentTimeMillis() -> Int64 {
        return Int64(self.timeIntervalSince1970)
    }
}

这是文档:链接

iOS 版、Swift iPhone 版、Facebook 、OAuth-2.0

评论


答: 暂无答案