darwin-morocho / flutter-facebook-auth

A flutter plugin to add login with facebook in your flutter app
191 stars 124 forks source link

Facebook login works fine on android. Crashes app onTap on iOS without any debug console errors. Used to work on both. #366

Open Abdullah-RashedMW opened 5 months ago

Abdullah-RashedMW commented 5 months ago

What version are you using?

flutter_facebook_auth: 6.0.1

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

macOS 13.2.1

What platforms are you seeing the problem on?

iOS

pubspec.yaml

name: abee
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

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+8

environment:
  sdk: '>=2.19.6 <3.0.0'

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter
  flutter_phoenix: ^1.1.1
  flutter_bloc: ^8.1.2
  # flutter_svg: ^2.0.5
  introduction_screen: ^3.1.8
  dio: ^5.2.1
  animations: ^2.0.7
  easy_localization: ^3.0.1
  flutter_credit_card: ^3.0.6
  flutter_carousel_widget: ^2.0.2
  # image_picker: ^1.0.2
  shared_preferences: ^2.1.1
  gap: ^3.0.0
  cached_network_image: ^3.2.3
  # in_app_review: ^2.0.6
  webview_flutter: ^4.2.3
  # modal_bottom_sheet: ^2.1.2
  # device_preview: ^1.1.0
  # permission_handler: ^10.2.0
  # fluttertoast: ^8.2.1
  lottie: ^2.3.2
  # pinput: ^2.2.31
  accordion: ^2.5.1
  # credit_card_type_detector: ^3.0.0
  carousel_indicator: ^1.0.6
  local_auth: ^2.1.6
  is_first_run: ^1.0.0
  shimmer: ^3.0.0
  flutter_conditional_rendering: ^2.0.0
  pull_to_refresh: ^2.0.0
  app_settings: ^5.0.0
  firebase_core: ^2.15.0
  firebase_auth: ^4.7.1
  google_sign_in: ^6.1.4
  # intl_phone_field: ^3.2.0
  flutter_facebook_auth: ^6.0.1
  # dart_ipify: ^1.1.1
  connectivity_plus: ^4.0.1
  bottom_loader: ^0.2.2
  intl_phone_number_input: ^0.7.3+1
  http_parser: ^4.0.2
  image_cropper: ^5.0.0
  firebase_messaging: ^14.6.5
  flutter_local_notifications: ^16.1.0
  logger: ^2.0.1
  change_app_package_name: ^1.1.0
  flutter_screenutil: ^5.9.0
  persistent_bottom_nav_bar_v2: ^4.2.8

# flutter_native_splash:
#   android: true
#   ios: true
#   web: false

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^2.0.0
  flutter_native_splash: ^2.2.19
  flutter_launcher_icons: ^0.13.1
flutter_native_splash:
  fullscreen: true
  android: true
  ios: true
  web: false
  image: assets/images/png/Logo512whiteAndroid11.png
  color: "#28AEE4"
  image_dark: assets/images/png/Logo512whiteAndroid11.png
  color_dark: "#28AEE4"
  android_12:
    image: assets/images/png/Logo512whiteAndroid12.png
    image_dark: assets/images/png/Logo512whiteAndroid12.png
    # Splash screen background color.
    color: "#28AEE4"
    color_dark: "#28AEE4"
    # App icon background color
    # icon_background_color: "#111111"

flutter_launcher_icons:
  android: true
  min_sdk_android: 21
  image_path: "assets/icon/android-launcer-icon.png"
  # adaptive_icon_background: "#28AEE4"
  # adaptive_icon_foreground: "assets/icon/android-launcer-icon.png"
  ios: true
  image_path_ios: "assets/icon/ios-launcher-icon.png"
  # image_path_ios TODO provider better looking ios launcher icon
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    # - assets/images/svg/
    - assets/images/png/
    # - assets/images/webp/
    - assets/images/jpg/
    - assets/animations/
    - assets/languages/ar-DZ.json
    - assets/languages/en-US.json
  #   - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # 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: Poppins
      fonts:
        - asset: assets/fonts/Poppins-Black.ttf
        - asset: assets/fonts/Poppins-BlackItalic.ttf
        - asset: assets/fonts/Poppins-Bold.ttf
        - asset: assets/fonts/Poppins-BoldItalic.ttf
        - asset: assets/fonts/Poppins-ExtraBold.ttf
        - asset: assets/fonts/Poppins-ExtraBoldItalic.ttf
        - asset: assets/fonts/Poppins-ExtraLight.ttf
        - asset: assets/fonts/Poppins-ExtraLightItalic.ttf
        - asset: assets/fonts/Poppins-Italic.ttf
        - asset: assets/fonts/Poppins-Light.ttf
        - asset: assets/fonts/Poppins-LightItalic.ttf
        - asset: assets/fonts/Poppins-Medium.ttf
        - asset: assets/fonts/Poppins-MediumItalic.ttf
        - asset: assets/fonts/Poppins-Regular.ttf
        - asset: assets/fonts/Poppins-SemiBold.ttf
        - asset: assets/fonts/Poppins-SemiBoldItalic.ttf
        - asset: assets/fonts/Poppins-Thin.ttf
        - asset: assets/fonts/Poppins-ThinItalic.ttf
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

Describe the Bug

Facebook login function crashes when tapping the button responsible for the signInWithFacebook() function. It crashes right before FacebookAuth.instance. It seems to fail to get an instance on iOS. Same function is used on Android and it is working fine. iOS simulator is on iOS 16.4

Expected Behavior

Redirect to browser to proceed with login.

To Reproduce

No clear ways to reproduce. It was working fine up until very recently. Facebook app is set up correctly. Firebase is set up correctly. It just crashes without giving ant information inside the IDE. I can only see through the log output.

Relevant log output

Incident Identifier: F726195B-600E-4A9F-A3E8-7B7267C04FFB
CrashReporter Key:   3FC162F1-D3A9-C808-CD10-88D82B254374
Hardware Model:      MacBookAir10,1
Process:             Runner [31872]
Path:                /Users/USER/Library/Developer/CoreSimulator/Devices/6CE6184C-42E6-498F-BCD2-BBF0DDDD7E97/data/Containers/Bundle/Application/76F8AE18-6CA1-4BDE-9A32-34B0843B920C/Runner.app/Runner
Identifier:          com.mediaworldsoftware.abee
Version:             1.0.0 (8)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd_sim [1241]
Coalition:           com.apple.CoreSimulator.SimDevice.6CE6184C-42E6-498F-BCD2-BBF0DDDD7E97 [931]
Responsible Process: SimulatorTrampoline [764]

Date/Time:           2023-11-14 10:34:48.2210 +0300
Launch Time:         2023-11-14 10:34:26.5423 +0300
OS Version:          macOS 13.2.1 (22D68)
Release Type:        User
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  0

Last Exception Backtrace:
0   CoreFoundation                         0x180437324 __exceptionPreprocess + 160
1   libobjc.A.dylib                        0x180051274 objc_exception_throw + 56
2   FBSDKCoreKit                           0x104aaf0a8 -[FBSDKInternalUtility validateFacebookReservedURLSchemes] + 0 (FBSDKInternalUtility.m:468)
3   FBSDKLoginKit                          0x1047098ec LoginManager.logInParameters(configuration:loggingToken:authenticationMethod:) + 376 (LoginManager.swift:515)
4   FBSDKLoginKit                          0x104707724 LoginManager.performBrowserLogIn(handler:) + 1128 (LoginManager.swift:641)
5   FBSDKLoginKit                          0x104710df4 specialized LoginManager.logIn(permissions:handler:) + 800
6   FBSDKLoginKit                          0x1047062f4 LoginManager.commonLogIn(from:configuration:completion:) + 308
7   FBSDKLoginKit                          0x104706c7c LoginManager.logIn(permissions:from:handler:) + 464
8   flutter_facebook_auth                  0x10506cb00 FacebookAuth.login(permissions:flutterResult:) + 540 (FacebookAuth.swift:93)
9   flutter_facebook_auth                  0x10506bed0 FacebookAuth.handle(_:result:) + 928 (FacebookAuth.swift:44)
10  flutter_facebook_auth                  0x105071504 SwiftFlutterFacebookAuthPlugin.handle(_:result:) + 128 (SwiftFlutterFacebookAuthPlugin.swift:18)
11  flutter_facebook_auth                  0x105071598 @objc SwiftFlutterFacebookAuthPlugin.handle(_:result:) + 124
12  Flutter                                0x109945ab0 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 172
13  Flutter                                0x108f37a40 invocation function for block in flutter::PlatformMessageHandlerIos::HandlePlatformMessage(std::_LIBCPP_ABI_NAMESPACE::unique_ptr<flutter::PlatformMessage, std::_LIBCPP_ABI_NAMESPACE::default_delete<flutter::PlatformMessage> >) + 108
14  libdispatch.dylib                      0x180132ee4 _dispatch_call_block_and_release + 24
15  libdispatch.dylib                      0x180134708 _dispatch_client_callout + 16
16  libdispatch.dylib                      0x180143fd8 _dispatch_main_queue_drain + 1220
17  libdispatch.dylib                      0x180143b04 _dispatch_main_queue_callback_4CF + 40
18  CoreFoundation                         0x18039a784 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
19  CoreFoundation                         0x180394de4 __CFRunLoopRun + 1912
20  CoreFoundation                         0x180394254 CFRunLoopRunSpecific + 584
21  GraphicsServices                       0x188eb7c9c GSEventRunModal + 160
22  UIKitCore                              0x10d4daff0 -[UIApplication _run] + 868
23  UIKitCore                              0x10d4def3c UIApplicationMain + 124
24  Runner                                 0x1040e2b08 main + 64 (AppDelegate.swift:6)
25  dyld_sim                               0x104351514 start_sim + 20
26  dyld                                   0x104545e50 start + 2544
27  ???                             0x7757000000000000 ???

flutter doctor -v

[✓] Flutter (Channel stable, 3.10.6, on macOS 13.2.1 22D68 darwin-arm64, locale
    en-JO)
    • Flutter version 3.10.6 on channel stable at
      /Users/mediaworld/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f468f3366c (4 months ago), 2023-07-12 15:19:05 -0700
    • Engine revision cdbeda788a
    • Dart version 3.0.6
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/mediaworld/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

[✗] Chrome - develop for the web (Cannot find Chrome executable at
    /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2022.3)
    • 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
      17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.84.2)
    • VS Code at /Users/mediaworld/Desktop/Visual Studio Code.app/Contents
    • Flutter extension version 3.76.0

[✓] Connected device (3 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        •
      android-arm64 • Android 13 (API 33) (emulator)
    • iPhone 14 Plus (mobile)     • 6CE6184C-42E6-498F-BCD2-BBF0DDDD7E97 • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)             • macos                                •
      darwin-arm64  • macOS 13.2.1 22D68 darwin-arm64

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

! Doctor found issues in 1 category.

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>3abee</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>abee</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>
                <string>MY_FB_APP_ID</string>
                <string>MY_GOOGLE_CLIENT_ID</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>FacebookAppID</key>
    <string>MY_FB_APP_ID</string>
    <key>FacebookClientToken</key>
    <string>MY_FB_CLIENT_TOKEN</string>
    <key>FacebookDisplayName</key>
    <string>3abee</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSFaceIDUsageDescription</key>
    <string>Extra security</string>
    <key>UIApplicationSupportsIndirectInputEvents</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIStatusBarHidden</key>
    <false/>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
        <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, '12.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__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

AndroidManifest.xml

No response

MainActivity.java

No response

MainActivity.kt

No response

index.html

No response

Info.plist (macOS)

No response

darwin-morocho commented 5 months ago

@Abdullah-RashedMW log out put says that the login function was called but it crashed the app. Some times this is due a bad sdk configuration. check your info.plist

instead of

<array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>MY_FB_APP_ID</string>
                <string>MY_GOOGLE_CLIENT_ID</string>
            </array>
        </dict>
    </array>

try with , replace 1718579621943661 with your app id

<array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb1718579621943661</string>
                                 <string>com.googleusercontent.apps.{your-app-specific-url}</string>
            </array>
        </dict>
    </array>

And don't forget to add

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>fbapi</string>
  <string>fb-messenger-share-api</string>
</array>