darwin-morocho / flutter-facebook-auth

A flutter plugin to add login with facebook in your flutter app
197 stars 139 forks source link

Unable to login on iOS with Facebook app #401

Closed tantzygames closed 5 months ago

tantzygames commented 5 months ago

What version are you using?

6.1.1

What OS and version are you using to local deploy your application?

macOS 14.3.1

What platforms are you seeing the problem on?

iOS

pubspec.yaml

description: A new Flutter project.

# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 2024.05.02+569

environment:
  sdk: ">=3.0.0 <4.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2

  firebase_core: ^2.15.0
  firebase_analytics: ^10.4.4
  firebase_auth: ^4.7.0
  cloud_firestore: ^4.8.3
  cloud_functions: ^4.3.4
  firebase_storage: ^11.2.5
  firebase_messaging: ^14.2.1
  firebase_in_app_messaging: ^0.7.3+4
  firebase_crashlytics: ^3.3.4
  google_sign_in: ^6.1.4
  sign_in_with_apple: ^6.1.0

  get: ^4.6.5
  rxdart: ^0.27.7
  http: ^1.0.0
  intl: ^0.19.0
  url_launcher: ^6.1.12
  shared_preferences: ^2.2.0
  just_audio: ^0.9.34
  in_app_review: ^2.0.6
  latlong2: ^0.9.0
  flex_color_scheme: ^7.1.2
  animations: ^2.0.7
  flutter_svg: ^2.0.7
  protobuf: ^3.0.0
  protoc_plugin: ^21.0.2
  rsa_encrypt: ^2.0.0
  path: ^1.8.2
  path_provider: ^2.0.15
  package_info_plus: ^8.0.0
  carousel_slider: ^4.2.1
  rive: ^0.12.4
  flutter_vibrate: ^1.3.0
  numberpicker: ^2.1.2
  cached_network_image: ^3.2.3
  flutter_cache_manager: ^3.3.1
  flutter_animate: ^4.2.0
  home_widget: ^0.5.0
  percent_indicator: ^4.2.3
  html: ^0.15.4
  flutter_html: ^3.0.0-beta.2
  glitters: ^0.4.0
  csv: ^6.0.0
  iso8601_duration: ^0.0.4
  share_plus: ^9.0.0
  visibility_detector: ^0.4.0+2

  image_picker: ^1.0.7
  image_cropper: ^5.0.1

  # VIDEO
  video_player: ^2.7.0

  # Barcode scanner
  camera: ^0.10.5+5
  google_mlkit_barcode_scanning: ^0.12.0

  # Integrations
  flutter_dotenv: ^5.1.0
  health: ^10.2.0
  permission_handler: ^11.3.1
  flutter_health_connect: ^1.2.3
  open_settings: ^2.0.2
  intercom_flutter: ^7.8.3
  braze_plugin: ^10.1.0
  in_app_purchase: ^3.2.0
  flutter_inapp_purchase: ^5.6.1
  flutter_facebook_auth: ^6.1.1
  advertising_id: ^2.6.0
  adjust_sdk: ^4.37.1
  sentry_flutter: ^8.1.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^3.0.2
  flutter_launcher_icons: ^0.13.1
  patrol: ^3.6.1
  patrol_finders: ^2.0.2

flutter_icons:
  ios: true
  image_path_ios: "icon/icon_ios.png"
  android: true
  image_path_android: "icon/icon_android.png"
  adaptive_icon_background: "icon/icon_background.png"
  adaptive_icon_foreground: "icon/icon_foreground.png"

# The following section is specific to Flutter packages.
flutter:
  uses-material-design: true
  assets:
    - .env
    - assets/
    - assets/audio/
    - assets/fonts/
    - assets/images/
    - assets/images/icons/
    - assets/images/emojis/

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    - family: Ivar
      fonts:
        - asset: assets/fonts/ivar_display_regular.ttf
    - family: Roboto Tammy
      fonts:
        - asset: assets/fonts/Roboto-Light.ttf
          weight: 300
        - asset: assets/fonts/Roboto-LightItalic.ttf
          style: italic
          weight: 300
        - asset: assets/fonts/Roboto-Regular.ttf
          weight: 400
        - asset: assets/fonts/Roboto-Italic.ttf
          style: italic
          weight: 400
        - asset: assets/fonts/Roboto-Medium.ttf
          weight: 500
        - asset: assets/fonts/Roboto-MediumItalic.ttf
          style: italic
          weight: 500
        - asset: assets/fonts/Roboto-Bold.ttf
          style: italic
          weight: 700
        - asset: assets/fonts/Roboto-boldItalic.ttf
          style: italic
          weight: 700
    - family: Roboto Condensed
      fonts:
        - asset: assets/fonts/Roboto-Condensed.ttf
        - asset: assets/fonts/Roboto-CondensedItalic.ttf
          style: italic
        - asset: assets/fonts/Roboto-BoldCondensed.ttf
          weight: 700
        - asset: assets/fonts/Roboto-BoldCondensedItalic.ttf
          style: italic
          weight: 700
    - family: Roboto Mono
      fonts:
        - asset: assets/fonts/Roboto-Mono.ttf

  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

Describe the Bug

If I delete the Facebook app I am able to login using the Facebook website. With the Facebook app installed it loops between the Facebook website and app, with the only other choice to cancel.

This is happening in debug and release versions for multiple users/devices

Expected Behavior

I expect the Facebook app to return to my app with the user credentials instead of returning to the website page.

To Reproduce

  1. I see system dialogue App Wants to Use "facebook.com" to Sign In and continue
  2. Facebook website window appears with dialogue asking "Open in "Facebook"? I choose Open
  3. Facebook app opens saying "You previously logged in to App with Facebook Would you like to continue? I choose "Continue as Jonny"
  4. Facebook app closes and returns to website window with options: Cancel, Log in With the Facebook App, and Forgotten password.

If I choose Log in With the Facebook App, it repeats steps 3 & 4. If I choose Cancel it returns to my app with LoginStatus.cancelled.

Relevant log output

No response

flutter doctor -v

[✓] Flutter (Channel stable, 3.19.6, on macOS 14.3.1 23D60 darwin-arm64, locale en-AU)
    • Flutter version 3.19.6 on channel stable at /Users/jonny/Code/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (3 weeks ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/jonny/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    ! CocoaPods 1.12.0 out of date (1.13.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods for instructions.

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

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/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.15+0-b2043.56-8887301)

[✓] Connected device (4 available)
    • iPhone 6s (mobile)         • 03086f2aaae3f4193b11a9f55c629e841c48f86f • ios            • iOS 14.4.1 18D61
    • iPhone 15 Pro Max (mobile) • EECFDADE-84A0-4CDE-B46C-A57ED606E80E     • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator)
    • macOS (desktop)            • macos                                    • darwin-arm64   • macOS 14.3.1 23D60 darwin-arm64
    • Chrome (web)               • chrome                                   • web-javascript • Google Chrome 124.0.6367.119

[✓] Network resources
    • All expected network resources are available.

Info.plist (iOS)

<?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>CADisableMinimumFrameDurationOnPhone</key>
    <true/>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleDisplayName</key>
    <string>App Name</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>appname</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            <string>bundleid</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fbXXXXXX</string>
                <string>bundleid</string>
            </array>
        </dict>
    </array>
    <key>GIDClientID</key>
    <string>XXXX.apps.googleusercontent.com</string>
    <key>FacebookAppID</key>
    <string>XXXXXX</string>
    <key>FacebookClientToken</key>
    <string>XXXXXXX</string>
    <key>FacebookDisplayName</key>
    <string>App Name</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fb-messenger-share-api</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
    </array>
    <key>FirebaseDynamicLinksCustomDomains</key>
    <array>
        <string>app url</string>
    </array>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSCameraUsageDescription</key>
    <string>We would like access to the camera for profile and progress images, and for barcode scanning</string>
    <key>NSHealthShareUsageDescription</key>
    <string>We will sync your data with the Apple Health app to give you better insights</string>
    <key>NSHealthUpdateUsageDescription</key>
    <string>We will sync your data with the Apple Health app to give you better insights</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>This app does not use the microphone</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>We would like access to the photo library to choose profile and progress images</string>
    <key>NSUserTrackingUsageDescription</key>
    <string>We use tracking for our internal analytics</string>
    <key>NSUserActivityTypes</key>
    <array>
        <string>ConfigurationIntent</string>
    </array>
    <key>UIApplicationSupportsIndirectInputEvents</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIRequiresFullScreen</key>
    <true/>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
</dict>
</plist>

Podfile (iOS)

# Uncomment this line to define a global platform for your project
platform :ios, '13.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

  target 'RunnerUITests' do
      inherit! :complete
    end
end

post_install do |installer|
#   installer.pods_project.build_configurations.each do |config|
#     config.build_settings["EXCLUDED_ARCHS[sdk=*]"] = "arm64"
# #     config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
#   end
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
    end
    target.build_configurations.each do |config|
      if Gem::Version.new($iOSVersion) > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
      end
    end
  end
end

AndroidManifest.xml

No response

MainActivity.java

No response

MainActivity.kt

No response

index.html

No response

Info.plist (macOS)

No response

tantzygames commented 5 months ago

My bad, it turns out I was overriding the callback function in AppDelegate.swift as a result of implementing Braze