darwin-morocho / flutter-facebook-auth

A flutter plugin to add login with facebook in your flutter app
193 stars 127 forks source link

App not found error, facebook login screen shown in in-app-browser instead of the app (iOS) #198

Closed Seferi closed 2 years ago

Seferi commented 2 years ago

On Android everything works flawlessly. On iOS, we are getting an facebook app not found error and facebook login screen is shown in in-app-browser afterwards.

Environment flutter doctor -v

[✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-arm, locale en-DE)
    • Flutter version 2.5.3 at /Users/user/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (9 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/user/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Users/user/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7784292/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.1, Build version 13A1030d
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Users/user/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7784292/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] Android Studio (version 2020.3)
    • Android Studio at /Users/berkersen/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7784292/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] IntelliJ IDEA Community Edition (version 2021.2.3)
    • IntelliJ at /Users/berkersen/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/212.5457.46/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (2 available)
    • iPhone 12 Pro (mobile)  • ios  • com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 96.0.4664.55

• No issues found!

pubspec.yaml

name: userApp
description: A new Flutter application.

version: 1.0.2+1

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  flutter_localizations:
    sdk: flutter

  get_it: ^7.1.3
  flutter_bloc: ^7.0.1
  dio: ^4.0.0
  equatable: ^2.0.2
  intl: ^0.17.0
  shared_preferences: ^2.0.6
  image_picker: ^0.8.3+2
  flutter_secure_storage: ^4.2.0
  cached_network_image: ^3.0.0
  package_info: ^2.0.2
  url_launcher: ^6.0.4
  permission_handler: ^8.0.1
  tuple: ^2.0.0
  complex: ^0.7.2
  device_info: ^2.0.2
  video_player: ^2.1.4
  fl_chart: ^0.36.4
  flutter_html: ^2.0.0
  flutter_facebook_auth: ^3.5.0
  firebase_core: ^1.10.0
  firebase_messaging: ^11.1.0
  google_sign_in: ^5.0.4
  sign_in_with_apple: ^3.0.0
  share: ^2.0.4
  in_app_purchase: ^1.0.5
  firebase_crashlytics: ^2.0.4
  in_app_purchase_ios: ^0.1.3+3
  sqflite: ^2.0.0+4
  path: ^1.8.0
  sqflite_common_ffi:
  connectivity_plus: ^2.0.3

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:

  uses-material-design: true

  assets:
      - assets/icons/
      - assets/json/
      - lang/de.json
      - lang/en.json

  fonts:
    - family: RobotoCondensed
      fonts:
        - asset: assets/fonts/roboto_condensed/RobotoCondensed-Bold.ttf
          weight: 700

Info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(DISPLAY_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                Deleted for security reasons
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>FacebookAppID</key>
    <string>Deleted for security reasons</string>
    <key>FacebookClientToken</key>
    <string>Deleted for security reasons</string>
    <key>FacebookDisplayName</key>
    <string>userApp</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fbapi20130214</string>
        <string>fbapi20130410</string>
        <string>fbapi20130702</string>
        <string>fbapi20131010</string>
        <string>fbapi20131219</string>
        <string>fbapi20140410</string>
        <string>fbapi20140116</string>
        <string>fbapi20150313</string>
        <string>fbapi20150629</string>
        <string>fbapi20160328</string>
        <string>fbauth</string>
        <string>fb-messenger-share-api</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
        <string>https</string>
        <string>http</string>
    </array>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    <key>NSAppleMusicUsageDescription</key>
    <string>Enable myApp to Uses for music</string>
    <key>NSCameraUsageDescription</key>
    <string>Enable myApp to access your camera to capture your photo</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>Enable myApp to access mic to record your voice</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Enable myApp to access to Photo Lib</string>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIStatusBarStyle</key>
    <string>UIStatusBarStyleLightContent</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
</dict>
</plist>

AppDelegate.swift

import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    let controller : FlutterViewController = window?.rootViewController as! FlutterViewController

    let methodChannel = FlutterMethodChannel(name: "deleted for security reasons", binaryMessenger: controller.binaryMessenger)
    let eventChannel = FlutterEventChannel(name: "deleted for security reasons", binaryMessenger: controller.binaryMessenger)

    let audioService: AudioStreamService = AudioStreamService()

    methodChannel.setMethodCallHandler({
      (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in

        if call.method == "setup" {
            let args = call.arguments as? Dictionary<String, Any>
            let sampleRate = args?["sampleRate"] as? Double

            audioService.setUp(rate: sampleRate)
            result(audioService.preferredBufferSize)
        }

        if call.method == "start" {
            let res: String? = audioService.startRecording()
            result(res ?? "Recording")
        }

        if call.method == "stop" {
            let res: String? = audioService.stopRecording()
            result(res ?? "Stopped")
        }
    })

    eventChannel.setStreamHandler(audioService)

    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

To Reproduce

await repository.logoutFacebook();

    LoginResult loginResult = await FacebookAuth.instance.login();

    if (loginResult.status == LoginStatus.success) {
      AccessToken accessToken = loginResult.accessToken!;
      print(accessToken.toJson());

      FacebookUserCredential fbCredential =
      FacebookUserCredential.fromJSON(accessToken.toJson());

      UserCredential credential = UserCredential(
        authMethod: AuthenticationMethod.facebook,
        facebookToken: fbCredential.token,
      );

      return Result<UserCredential>(data: credential);

Expected behavior We expect to happen that the facebook app launches and asks for the permission to authorise the login and then our app logins via facebook credentials. Instead the in-app-browser is launched with the facebook login screen.

darwin-morocho commented 2 years ago

@Seferi I have tested. in my iPhone X with iOS 15 without any problem. Please fix your info.plist because it is not showing correctly and add more info about the device that you are using

Seferi commented 2 years ago

@darwin-morocho Thanks mate, I tried to fix the info.plist but no matter what I tried, it shows up as it is. › this character recognized as a quote. Any suggestions ? I tried it on iPhone Xs, iOS 15.1

darwin-morocho commented 2 years ago

try to use the last version of this plugin and also if the problem persists try to clone the repo and run the example folder with your credentials

Seferi commented 2 years ago

ok, I tried the latest version of the plugin. Problem persists and this is the error I'm getting:

FBSDKLog: starting with Graph API v2.4, GET requests for /facebookId/aem_conversion_configs should contain an explicit "fields" parameter flutter: Transition { currentState: LoginIsSignUpState(), event: LoginButtonPressed { networkType: AuthenticationMethod.facebook, userCredential: null}, nextState: Login Failure ( error: Instance of 'Error') } [connection] nw_resolver_start_query_timer_block_invoke [C26.1] Query fired: did not receive all answers in time for graph.facebook.com:443 [connection] nw_resolver_start_query_timer_block_invoke [C26.2] Query fired: did not receive all answers in time for graph.facebook.com:443

darwin-morocho commented 2 years ago

Have you tried using the example project?

Also this plugin doesn't have the next class FacebookUserCredential and AuthenticationMethod so the next error

flutter: Transition { currentState: LoginIsSignUpState(), event: LoginButtonPressed { networkType: AuthenticationMethod.facebook, userCredential: null}, nextState: Login Failure ( error: Instance of 'Error') }
[connection] nw_resolver_start_query_timer_block_invoke [C26.1] Query fired: did not receive all answers in time for graph.facebook.com:443
[connection] nw_resolver_start_query_timer_block_invoke [C26.2] Query fired: did not receive all answers in time for graph.facebook.com:443

is not of this plugin

Seferi commented 2 years ago

try to use the last version of this plugin and also if the problem persists try to clone the repo and run the example folder with your credentials

I will clone the repo and try it as next step..

Seferi commented 2 years ago

I cloned the app and tried to run on the iOS device but build fails and I get this error:

error: No profiles for 'app.meedu.facebookAuthExample' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'app.meedu.facebookAuthExample'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'Runner' from project 'Runner')

Automatic signing is enabled and for the life of me I couldn't find-allowProvisioningUpdates argument anywhere in Xcode so I could enable..

Seferi commented 2 years ago

When I tap the facebook login in our app, in-app browser launches with the facebook login screen without the user info. Here is the log:

SELECT * FROM cacheObject WHERE touched < ? ORDER BY touched DESC LIMIT 100 OFFSET 200 (
    8637611985486
)
SELECT * FROM cacheObject WHERE touched < ? LIMIT 100 (
    9627405395457
)
DELETE FROM cacheObject WHERE _id IN ()
changed 0
[tcp] tcp_input [C10.1:3] flags=[R] seq=632217078, ack=0, win=0 state=CLOSED rcv_nxt=632217078, snd_una=1262899556[tcp] tcp_input [C10.1:3] flags=[R] seq=533227038, ack=0, win=0 state=CLOSED rcv_nxt=546735645, snd_una=1262899556
[connection] nw_resolver_start_query_timer_block_invoke [C10] Query fired: did not receive all answers in time for graph.facebook.com:443
darwin-morocho commented 2 years ago

go to your Facebook account and in your settings delete your app and try the login flow again

darwin-morocho commented 2 years ago

closed by inactivity