darwin-morocho / flutter-facebook-auth

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

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FBSDKApplicationDelegate initializeSDK]: unrecognized selector sent to instance #306

Closed alpeshshiyal closed 1 year ago

alpeshshiyal commented 1 year ago

What version are you using?

flutter_facebook_auth:4.4.1

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

maOS 12.6

What platforms are you seeing the problem on?

iOS

pubspec.yaml

name: fstore
publish_to: "none"
description: Mobile commerce app by Flutter

# 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 used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 3.0.7+3022

environment:
  sdk: ">=2.17.6 <3.0.0"
#  sdk: ">=2.17.1 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

  # common lib from
  inspireui: 1.1.8

  # Base
  intl: 0.17.0
  crypto: 3.0.2
  path_provider: 2.0.11
  url_launcher: 6.1.5
  localstorage: 4.0.0+1
  http: 0.13.5
  http_auth: 1.0.1
  share: 2.0.4
  tuple: 2.0.0
  shared_preferences: 2.0.15
  collection: 1.16.0
  quiver: 3.1.0
  async: 2.9.0
  html: 0.15.0
  vector_math: 2.1.2
  path: 1.8.2
  flutter_svg: 1.1.4

  # FIREBASE PACKAGES
  firebase_core: 1.21.1
  firebase_analytics: 9.3.3
  firebase_auth: 3.7.0
  firebase_remote_config: 2.0.16
  firebase_dynamic_links: 4.3.6
  cloud_firestore: 3.4.6

  # Additional Firebase packages. To prevent unexpected upgrade.
  firebase_core_platform_interface: 4.5.1
  firebase_analytics_platform_interface: 3.3.3
  firebase_auth_platform_interface: 6.6.0
  firebase_dynamic_links_platform_interface: 0.2.3+11
  firebase_messaging_platform_interface: 4.1.3
  firebase_remote_config_platform_interface: 1.1.15

  # PUSH NOTIFICATION
  firebase_messaging: 13.0.0
  notification_permissions: 0.6.1
  flutter_local_notifications: 9.9.1
  onesignal_flutter: 3.4.1

  # STATE MANAGEMENT
  provider: 6.0.3
  get_it: 7.2.0

  # SPLASH SCREEN, ONBOARD
  lottie: 1.4.2
  rive: 0.9.1

  # WEB TOOLS
  html_unescape: 2.0.0
  webview_flutter: 3.0.4
  webview_flutter_web: 0.1.0+4
  responsive_builder: 0.4.3
  flutter_inappwebview: # 5.4.3+7 - fix xcode 14
    git: https://github.com/inspireui/flutter_inappwebview

  # HTML render
  flutter_widget_from_html_core: 0.8.5+3
  fwfh_svg: 0.7.2
  fwfh_cached_network_image: 0.7.0+2
  fwfh_url_launcher: 0.6.1+3
  fwfh_chewie: 0.7.0+1
  fwfh_webview: 0.6.2+3

  # VIDEO
  youtube_player_iframe: ^3.0.4

  # MAP
  google_maps_flutter: 2.2.0
  geocode: 1.0.2
  location: 4.4.0

  # AUTHENTICATION
  the_apple_sign_in: 1.1.1
  flutter_facebook_auth: 4.4.1
#  flutter_facebook_auth: ^5.0.0
#  flutter_facebook_auth: ^4.3.4+2
  google_sign_in: 5.4.1
  sms_autofill: 2.2.0

  # PERMISSION
  # Don't upgrade permission_handler to 10+ version. file_picker is not ready for Android 13.
  permission_handler: 9.2.0

  # FILES, IMAGES
  file_picker: 5.0.1
  cached_network_image: 3.2.2
  image: 3.2.0
  transparent_image: 2.0.0
  image_picker: 0.8.5+3
  flutter_native_image: 0.0.6+1
  flutter_cache_manager: 3.3.0
  wechat_assets_picker: 8.0.2
  photo_manager: 2.2.1

  # TOOLS
  google_fonts: 3.0.1
  random_string: 2.3.1
  json_annotation: 4.6.0
  timeago: 3.3.0
  universal_platform: 1.0.0+1
  uuid: 3.0.6
  easy_debounce: 2.0.2+1
  devicelocale: 0.5.5
  visibility_detector: 0.3.3
  rate_my_app: 1.1.3
  flutter_linkify: 5.0.2
  gms_check: 1.0.0
  new_version: 0.3.1
  video_player: 2.4.7
  in_app_update: 3.0.0
  google_mobile_ads: 2.0.1

  # UI
  flutter_spinkit: 5.1.0
  smooth_page_indicator: 1.0.0+2
  animated_text_kit: 4.2.2
  flash: 2.0.3+3
  flutter_staggered_grid_view: 0.6.2
  pin_code_fields: 7.4.0
  country_code_picker: 2.0.2
  country_pickers: 2.0.0
  dropdown_search: 5.0.2
  intro_slider: 3.0.10
  flutter_zoom_drawer: 3.0.3
  extended_image: 6.3.0
  dotted_decoration: 2.0.0
  awesome_card: 1.1.7
  maps_launcher: 2.0.1
  qr_code_scanner: 1.0.1
  flutter_calendar_carousel: 2.4.0
  sticky_headers: 0.3.0+2
  jumping_dot: ^0.0.4

  # FACEBOOK
  facebook_app_events: ^0.17.1
#  facebook_app_events: ^0.18.1
#  facebook_app_events: ^0.14.0

  ### Native Payment
  razorpay_flutter: 1.3.2
  paytm_allinonesdk: 1.1.8
  flutter_paystack:
    git: https://github.com/inspireui/flutter_paystack
  flutterwave_standard: # 1.0.4 - fix XCode 14
    git: https://github.com/inspireui/Flutterwave

  ### Flutter 3 fix warning
  charts_flutter:
    git:
      url: https://github.com/inspireui/charts.git
      path: charts_flutter
  flutter_swiper_null_safety:
    git: https://github.com/inspireui/flutter_swiper_null_safety
  flare_flutter:
    git:
      url: https://github.com/inspireui/Flare-Flutter.git
      ref: fd4bcba22aae4c028286e453deeb78f3311e689a
      path: flare_flutter
  pull_to_refresh:
    git: https://github.com/inspireui/flutter_pulltorefresh

  ###---- Some extra featureen is disable by default -----###
  ### πŸ’³ Facebook Ads
  ### Search "Enable Facebook Ads" & uncomment to use  - https://tppr.me/9Pkf9
  # facebook_audience_network: 1.0.0-nullsafety.0

dev_dependencies:
  flutter_lints: 2.0.1
  flutter_native_splash: 2.2.8

### Enable to use Flutter Test Driver
#  flutter_driver:
#    sdk: flutter
#  test: 1.16.5
#  dependency_validator: ^3.1.2  # pub run dependency_validator

### Enable Generate Icon library
  flutter_launcher_icons: ^0.9.2
#  Run this script to generate the app icon: flutter pub run flutter_launcher_icons:main

flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/images/app_icon.png"
  remove_alpha_ios: true

flutter:
  uses-material-design: true
  assets:
    - lib/config/
    - lib/config/states/
    - lib/config/stories/
    - assets/icons/brands/
    - assets/icons/credit_cards/
    - assets/icons/tabs/
    - assets/icons/payment/
    - assets/icons/logins/
    - assets/images/
    - assets/images/country/
    - assets/images/favicon/
    - assets/html/
    - google_fonts/

### Uncomment to use custom font
#  fonts:
#    - family: Your Custom Font
#      fonts:
#      - asset: google_fonts/GE-Hili-Book.ttf

flutter_intl:
  enabled: true
  use_deferred_loading: true

Describe the Bug

App crashes while running on iOS device and getting following error in console

Expected Behavior

App not running only getting white screen

To Reproduce

run application on iOS device using flutter_facebook_auth : 4.4.1 and facebook_app_events: ^0.17.1

Relevant log output

No response

flutter doctor -v

Doctor summary (to see all details, run flutter doctor -v):
[βœ“] Flutter (Channel stable, 3.3.0, on macOS 12.6 21G115 darwin-x64, locale
    en-GB)
[βœ—] Android toolchain - develop for Android devices
    βœ— Unable to locate Android SDK.
      Install Android Studio from:
      https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK
      components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup
      for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[βœ“] Xcode - develop for iOS and macOS (Xcode 13.0)
[βœ“] Chrome - develop for the web
[βœ“] Android Studio (version 2021.3)
[βœ“] Connected device (4 available)
[βœ“] HTTP Host Availability

! 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>CFBundleAllowMixedLocalizations</key>
    <true/>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>Sazuna</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleLocalizations</key>
    <array>
        <string>en</string>
        <string>hi</string>
        <string>es</string>
        <string>fr</string>
        <string>ar</string>
        <string>ru</string>
        <string>id</string>
        <string>ja</string>
        <string>ko</string>
        <string>vi</string>
        <string>ro</string>
        <string>tr</string>
        <string>it</string>
        <string>de</string>
        <string>pt</string>
        <string>hu</string>
        <string>he</string>
        <string>th</string>
        <string>nl</string>
        <string>sr</string>
        <string>pl</string>
        <string>fa</string>
        <string>uk</string>
        <string>bn</string>
        <string>ta</string>
        <string>cs</string>
        <string>sv</string>
        <string>fi</string>
        <string>el</string>
        <string>km</string>
        <string>kn</string>
        <string>mr</string>
        <string>ms</string>
        <string>bs</string>
        <string>lo</string>
        <string>sk</string>
        <string>sw</string>
        <string>zh</string>
        <string>my</string>
        <string>sq</string>
    </array>
    <key>CFBundleName</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(MARKETING_VERSION)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb853439342016798</string>
                <string>com.googleusercontent.apps.412823237422-pf5dr3f75n6r201u24ocioin54u3cseq</string>
                <string>paytmMID</string>
                <string>com.inspireui.mstore.flutter</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>$(CURRENT_PROJECT_VERSION)</string>
    <key>FacebookAppID</key>
    <string>853439342016798</string>
    <key>FacebookClientToken</key>
    <string>a2cc1dbe8246b24190ba4ef27a8615f7</string>
    <key>FacebookDisplayName</key>
    <string>Sazuna</string>
    <key>FirebaseAppDelegateProxyEnabled</key>
    <true/>
    <key>FirebaseDeepLinkPasteboardRetrievalEnabled</key>
    <false/>
    <key>FirebaseScreenReportingEnabled</key>
    <true/>
    <key>GADApplicationIdentifier</key>
    <string>ca-app-pub-7432665165146018~2664444130</string>
    <key>ITSAppUsesNonExemptEncryption</key>
    <false/>
    <key>LSApplicationQueriesSchemes</key>
    <array>
            <string>fbapi</string>
            <string>fb-messenger-share-api</string>
            <string>fbauth2</string>
            <string>fbshareextension</string>
    </array>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSAllowsArbitraryLoadsInWebContent</key>
        <true/>
    </dict>
    <key>NSCameraUsageDescription</key>
    <string>This app requires access to the camera for QR Code or Barcode scanner feature which can be access from the search bar</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>Need current location access</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Get your current location for delivery</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>This app requires access to the photo library to select a profile photo which will be used as a chat image for the Chat Feature.</string>
    <key>NSUserTrackingUsageDescription</key>
    <string>This identifier will be used to deliver personalized ads to you. "Ask App Not to track" will limit Advertisement network's ability to deliver relevant ads to you but will not reduce the number of ads you receive.</string>
    <key>SKAdNetworkItems</key>
    <array>
        <dict>
            <key>SKAdNetworkIdentifier</key>
            <string>cstr6suwn9.skadnetwork</string>
        </dict>
    </array>
    <key>UIBackgroundModes</key>
    <array>
        <string>fetch</string>
        <string>remote-notification</string>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIStatusBarHidden</key>
    <false/>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>io.flutter.embedded_views_preview</key>
    <string>YES</string>
</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'

# pod 'FBSDKCoreKit', '14.1.0'
# pod 'FBSDKLoginKit', '14.1.0'

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

# pod 'GoogleMaps', '3.5.0'
# pod 'FBSDKCoreKit', '>= 14.0.0'

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)
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 i386"

      if target.name == 'permission_handler_apple'
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
          '$(inherited)',

          ## dart: PermissionGroup.camera
          'PERMISSION_CAMERA=1',

          ## dart: PermissionGroup.photos
          'PERMISSION_PHOTOS=1'
        ]
      else
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
          '$(inherited)',
          'AUDIO_SESSION_MICROPHONE=0'
        ]
      end
    end
  end
end

target 'OneSignalNotificationServiceExtension' do
  use_frameworks!
  pod 'OneSignalXCFramework', '>= 3.4.3', '< 4.0'
end

# Fixes Flutter.framework in shell script build phase '[CP] Embed Pods Frameworks' error
install! 'cocoapods', :disable_input_output_paths => true

AndroidManifest.xml

No response

MainActivity.java

No response

MainActivity.kt

No response

index.html

No response

Info.plist (macOS)

No response

darwin-morocho commented 1 year ago

@alpeshshiyal try removing

    <key>CFBundleTypeRole</key>
            <string>Editor</string>

from

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb853439342016798</string>
                <string>com.googleusercontent.apps.412823237422-pf5dr3f75n6r201u24ocioin54u3cseq</string>
                <string>paytmMID</string>
                <string>com.inspireui.mstore.flutter</string>
            </array>
        </dict>
    </array>
alpeshshiyal commented 1 year ago

Still getting same error after applying above change in [info.plist file

look at this screenshot below Screenshot 2022-11-09 at 12 12 08 PM

darwin-morocho commented 1 year ago

you have a custom AppDelegate.swift and it seems you are overriding the func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { ... }

For more info check

https://github.com/darwin-morocho/flutter-facebook-auth/issues/261

https://github.com/darwin-morocho/flutter-facebook-auth/issues/6