darwin-morocho / flutter-facebook-auth

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

-canOpenURL: failed for URL: "fbapi:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)" #320

Closed elhui2 closed 1 year ago

elhui2 commented 1 year ago

What version are you using?

5.0.7

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

Mac OS 12.4

What platforms are you seeing the problem on?

iOS

pubspec.yaml

name: appName
description: App Description

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

# Version del app Build Number
version: 1.9.12+8014

environment:
  sdk: ">=2.7.0 <3.0.0"

# TODO: Limpiar dependencias
dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.3
  flutter_svg: ^0.22.0
  http: ^0.13.3
  http_parser: ^4.0.0
  toast: ^0.1.5
  percent_indicator: "^2.1.7+2"
  flutter_facebook_auth: ^5.0.7
  intl: ^0.17.0
  sqflite: ^1.1.6+4
  shared_preferences: ^2.0.6
  firebase_auth: ^3.1.1
  firebase_auth_web: ^3.1.0
  firebase_core: ^1.5.0
  google_sign_in: ^4.0.4
  provider: ^4.0.0
  hexcolor: ^2.0.5
  qr_flutter: ^3.1.0
  google_maps_flutter: ^2.1.8
  url_launcher: ^5.0.0
  webview_flutter: ^2.0.14
  location: ^4.4.0
  bubble: ^1.1.9+1
  lottie: ^1.1.0
  sign_in_with_apple: ^3.2.0
  camera: ^0.5.8+17
  image_cropper: ^1.4.1
  image_picker: ^0.8.6
  cross_file: ^0.3.2
  geocoder: ^0.2.1
  path_provider: ^2.0.9

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_launcher_icons: ^0.9.2

# 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 Appicon.
flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/appicon.png"

# The following section is specific to Flutter.
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/logo-main.svg
    - assets/logo-dark.svg
    - assets/logo-green.svg
    - assets/ic-circle-dollar.svg
    - assets/ic-profile.svg
    - assets/ic-usd-flag.svg
    - assets/ic-eur-flag.svg
    - assets/ic-cad-flag.svg
    - assets/ic-gbp-flag.svg
    - assets/ic-google.svg
    - assets/ic-logout.svg
    - assets/ic-home-out.svg
    - assets/ic-rewards-out.svg
    - assets/ic-operations-out.svg
    - assets/ic-offices-out.svg
    - assets/ic-support-out.svg
    - assets/ic-platinum.svg
    - assets/ic-platinum.png
    - assets/ic-whatsapp.svg
    - assets/ic-dollar.svg
    - assets/ic-peso.svg
    - assets/banner.png
    - assets/sampler-1.jpg
    - assets/sampler-qr.svg
    - assets/logo-animation.json
    - assets/logo-animation2.json
    - assets/logo-citibanamex.svg
    - assets/logo-banco-azteca.svg
    - assets/logo-bbva.svg
    - assets/logo-banorte.svg
    - assets/logo-banxico.svg
    - assets/logo-hsbc.svg
    - assets/logo-intercam.svg
    - assets/logo-ixe.svg
    - assets/logo-santander.svg
    - assets/logo-scotiabank.svg
    - assets/terms-1.9.9.html
    - assets/points_table2.png
    - assets/profile_av.png
    - assets/logo_horizontal.svg
    - assets/appbar-back.png
    - assets/camera_front.svg
    - assets/camera_back.svg
    - assets/camera_large.svg

  # 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: SansPro
      fonts:
        - asset: fonts/sans_pro/SourceSansPro-Regular.ttf
        - asset: fonts/sans_pro/SourceSansPro-Bold.ttf
          weight: 700
        - asset: fonts/sans_pro/SourceSansPro-Italic.ttf
          style: italic
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

Describe the Bug

Hello I’m working with flutter_facebook_auth V ^5.0.7, I made all the configurations for Android and iOS, in Android the login works like charm (with this I rule out the miss configuration of facebook app panel)

In the flutter log don’t apear any errors but in the Xcode the log launch:

-canOpenURL: failed for URL: "fbapi:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

In the screen only appear the classic error in the top on a red ribbon. “Login Error: There is an error in loggin you into this application. Please try again latter”

I Read this links but i can’t find the solution

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

AppDelegate.swift

import UIKit
import Flutter
import Firebase
import GoogleMaps
import FBSDKCoreKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GMSServices.provideAPIKey("AIzXXXxxxxxxx-XXXXXXxxxxx")
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }

  override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

        let facebookAppId: String? = Bundle.main.object(forInfoDictionaryKey: "FacebookAppID") as? String
        if facebookAppId != nil && url.scheme!.hasPrefix("fb\(facebookAppId!)") && url.host ==  "authorize" {
              print("AppDelegate-> is login by facebook")
              return ApplicationDelegate.shared.application(app, open: url, options: options)
        }

        return false

  }
}

Expected Behavior

The success of the login on facebook

To Reproduce

On click in the Facebook Login.

Relevant log output

2023-01-04 19:03:47.980852-0600 Runner[56537:2303752] -canOpenURL: failed for URL: "fbapi:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

flutter doctor -v

[✓] Flutter (Channel stable, 2.10.5, on macOS 12.4 21F79 darwin-arm, locale es-419)
    • Flutter version 2.10.5 at /Users/elhui2/Library/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5464c5bac7 (9 months ago), 2022-04-18 09:55:37 -0700
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/elhui2/Library/Android/sdk
    • Platform android-33, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.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.11+0-b60-7772763)

[✓] VS Code (version 1.74.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.56.0

[✓] Connected device (2 available)
    • iPhone 11 (mobile) • 68C49347-3B82-48A3-AF5E-C2A28EF6A4A1 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-5 (simulator)
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 108.0.5359.124

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

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>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>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fbXXXXXXXXXX</string>
                <string>com.googleusercontent.apps.XXXXXXXXX-XXXXXXXXXXXXX</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>FacebookAppID</key>
    <string>XXXXXXXXXXXXX</string>
    <key>FacebookClientToken</key>
    <string>lakshjxxxxxxxxxxxxxx</string>
    <key>FacebookDisplayName</key>
    <string>App Name</string>
    <key>FacebookAutoLogAppEventsEnabled</key>
    <string>TRUE</string>
    <key>FacebookAdvertiserIDCollectionEnabled</key>
    <string>TRUE</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fb-messenger-share-api</string>
        <string>fbauth2</string>
    </array>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Necesitamos tu ubicacion para ofrecerte la mejor sucursal</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>Necesitamos tu ubicacion para ofrecerte la mejor sucursal</string>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</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>
    <true/>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Necesitas esta funcionalidad para seleccionar tu foto de perfíl</string>
    <key>NSCameraUsageDescription</key>
    <string>Necesitas esta funcionalidad para tomar tu foto de perfíl</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>Necesitas esta funcionalidad para tomar tu foto de perfíl</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'

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 1 year ago

@elhui2 In my opinion you don't need the next code in your AppDelegate.swift

override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

        let facebookAppId: String? = Bundle.main.object(forInfoDictionaryKey: "FacebookAppID") as? String
        if facebookAppId != nil && url.scheme!.hasPrefix("fb\(facebookAppId!)") && url.host ==  "authorize" {
              print("AppDelegate-> is login by facebook")
              return ApplicationDelegate.shared.application(app, open: url, options: options)
        }

        return false

  }

You only should override that function if you have conflicts with another auth flows like Twitter.

elhui2 commented 1 year ago

Thanks a lot for take a look. I removed the code an got the same error:

-canOpenURL: failed for URL: "fbapi:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

Current AppDelegate.swift

import UIKit
import Flutter
import Firebase
import GoogleMaps
import FBSDKCoreKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GMSServices.provideAPIKey("XXXXXXXXXXXXXXX")
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}
darwin-morocho commented 1 year ago

@elhui2 sorry But I am not able to reproduce the issue, could you add the dart code that are you using? Also if you can provide me a temporally access to your project to run in my local machine to reproduce the issue that will be great

elhui2 commented 1 year ago

@darwin-morocho of course, now you have the access to the repo, thanks for all.

The file of login is: lib/library/facebook_login_button.dart

Any feedback is very welcome, it's my first app in the stores. Regards

darwin-morocho commented 1 year ago

@elhui2 finally this is not an issue of this plugin so I'm closing this

elhui2 commented 1 year ago

The app is in developer mode. so i can login with my account in android but not in iOS.

Please can you change the text of my api key in your previous response?

darwin-morocho commented 1 year ago

The app is in developer mode. so i can login with my account in android but not in iOS.

Please can you change the text of my api key in your previous response?

I have deleted the comment