pikaju / flutter-braintree

Flutter plugin that wraps the native Braintree SDKs. Enables payments with credit cards, PayPal, Google Pay and more.
https://pub.dev/packages/flutter_braintree
MIT License
64 stars 126 forks source link

[IOS] The implementation of the plugin as shown in the example causes problem with Facebook login (infinite loop when login) #122

Closed nicolobozzato closed 1 year ago

nicolobozzato commented 2 years ago

The implementation of the AppDelegate.swift as shown in the example, causes this problem with Facebook Login (I tried both of the main plugin flutter_facebook_auth and flutter_login_facebook).

The problem is this: If the user is not logged in the browser and has the native Facebook app installed, he gets trapped in an infinite loop between webview and app.

The indicted function is this one

    override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        if url.scheme == "com.example.flutterBraintreeExample.payments" {
            return BTAppSwitch.handleOpen(url, options:options)
        }

        return false
    }

I found the problem gets solved if I change it to

    override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        if url.scheme == "com.example.flutterBraintreeExample.payments" {
            return BTAppSwitch.handleOpen(url, options:options)
        }

        return super.application(app, open: url, options:  options);
    }

In this way if the link does not concern the work of braintree the url can be handled normally. This really gave me an headache :) I'm not very expert in Ios, so I'm open to comment, I'll try to send a PR ASAP at most in the weekend hopefully