darwin-morocho / flutter-facebook-auth

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

Login not work in IOS #263

Closed giovannilima262 closed 2 years ago

giovannilima262 commented 2 years ago

What version are you using?

4.4.0

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

macOS 14.4

What platforms are you seeing the problem on?

iOS

pubspec.yaml

name: mobile_app
description: A new Flutter project.

# 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: 4.3.2+359

environment:
  sdk: ">=2.6.0 <3.0.0"

publish_to: none

dependencies:
  flutter:
    sdk: flutter
  flutter_image_compress: ^1.1.0
  sleek_circular_slider: ^2.0.0
   # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  vibration: ^1.7.3
  flutter_swiper: ^1.1.6
  # simple_tooltip: ^0.1.16
  permission_handler: ^10.0.0
  photo_manager: ^2.1.4

  camera: ^0.9.8+1

  package_info: ^0.4.0+12
  device_info: ^0.4.1+5

  http: ^0.13.4
  path_provider: ^2.0.11
  provider: ^4.1.3
  shared_preferences: ^0.5.6+3
  intl: ^0.17.0

  flutter_localizations:
    sdk: flutter

  flutter_svg: ^0.22.0
  plugin_platform_interface: ^2.1.0
  image_picker: ^0.7.5
  transparent_image: ^1.0.0
  pull_to_refresh: ^2.0.0
  week_of_year: ^2.0.0

  audioplayers: ^1.0.1
  video_player: ^2.4.5
  open_file: ^3.0.1

  purchases_flutter: ^3.10.0
  flutter_inapp_purchase: ^5.2.0

  firebase_core: ^1.18.0

  firebase_auth: ^3.3.20
  google_sign_in: ^5.3.3

  cloud_firestore: ^3.1.18
  firebase_storage: ^10.2.18
  firebase_dynamic_links: ^0.5.1
  firebase_analytics: ^9.1.10
  #flutter_login_facebook: ^1.5.0+1
  flutter_facebook_auth: ^4.4.0

  share: ^0.6.5+4

  smooth_star_rating: ^1.1.1

  diacritic: ^0.1.1

  wakelock: ^0.1.3+4

  firebase_messaging: ^11.4.2

  #social_share: ^2.2.1
  # social_share_plugin: ^0.3.1+1
  flutter_share_me: ^0.9.2
  instagram_share: ^0.1.9

  screenshot: ^1.2.3
  appsflyer_sdk: ^5.2.0+1

  advertising_id: ^2.3.0

  rate_my_app: ^0.6.1+3

  synchronized: ^2.2.0+1

  flutter_native_timezone: ^2.0.0

  device_calendar: ^4.2.0
  sign_in_with_apple: ^4.0.0

  tuple: ^2.0.0

  # flutter_segment: ^3.0.0

  flutter_branch_sdk: ^5.1.1

  flutter_keyboard_visibility: ^5.3.0

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter_icons:
  android: true
  ios: true
  image_path: "assets/appIcons/PositivIcon1a.jpg"

  #TODO: Provide transparent logo for adaptive_icon_foreground and colorful background only for adaptive_icon_background
  adaptive_icon_foreground: "assets/appIcons/PositivIcon1a.jpg" 
  adaptive_icon_background: "#ffffff"

flutter_native_splash:
  image: assets/videos/backgroundFrame-4x-with-opacity-60-logo.jpg
  color: "e59978"

flutter:

  uses-material-design: true

  assets:
   - assets/appIcons/
   - assets/graphics/
   - assets/icons/
   - assets/images/
   - assets/videos/
   - assets/gifs/
   - assets/sounds/
   - locale/i18n_en.json
   - locale/i18n_pt_BR.json

  fonts:
    - family: Domus
      fonts:
        - asset: assets/fonts/Domus-App-Extrabold.ttf
          weight: 800
        - asset: assets/fonts/Domus-App-Bold.ttf
          weight: 700
        - asset: assets/fonts/Domus-App-Semibold.ttf
          weight: 600
        - asset: assets/fonts/Domus-App-Regular.ttf
          weight: 400
        - asset: assets/fonts/Domus-App-Light.ttf
          weight: 300
        - asset: assets/fonts/Domus-App-Extralight.ttf
          weight: 200
        - asset: assets/fonts/Domus-App-Ultralight.ttf
          weight: 100
        # - asset: assets/fonts/Domus-App-Bold-mini.ttf
          # style:

Describe the Bug

... fbLoginResult ??= await _facebookLogin.logIn( permissions: [FacebookPermission.email], ); ...

Current state: When calling the login function facebook, the modal opens normally and when going through the authentication screens I am redirected to the first facebook screen and nothing else happens.

Expected Behavior

After the last authentication confirmation option, be returned to the app with a successful authentication.

To Reproduce

Uploading RPReplay_Final1657213222.mov…

Relevant log output

No response

flutter doctor -v

[✓] Flutter (Channel stable, 3.0.3, on macOS 12.4 21F79 darwin-x64, locale pt-BR)
    • Flutter version 3.0.3 at /Users/giovannidelimaconceicao/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 676cefaaff (2 weeks ago), 2022-06-22 11:34:49 -0700
    • Engine revision ffe7b86a1e
    • Dart version 2.17.5
    • DevTools version 2.12.2

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/giovannidelimaconceicao/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • 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 4.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 1.8.0_242-release-1644-b3-6915495)

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

[✓] Connected device (3 available)
    • iPhone de giovanni (mobile) • 00008030-0005456A02FA402E • ios            • iOS 15.6 19G5046d
    • macOS (desktop)             • macos                     • darwin-x64     • macOS 12.4 21F79 darwin-x64
    • Chrome (web)                • chrome                    • web-javascript • Google Chrome 103.0.5060.114
    ! Error: iPhone de giovanni is busy: Fetching debug symbols for iPhone de giovanni. Xcode will continue when iPhone de
      giovanni is finished. (code -10)

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

! Doctor found issues in 1 category.
darwin-morocho commented 2 years ago

@giovannilima262 add your AppDelegate.swift and your Info.plist

giovannilima262 commented 2 years ago

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>CFBundleLocalizations</key>
    <array>
        <string>en</string>
        <string>pt</string>
    </array>
    <key>CFBundleName</key>
    <string>[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>
                <string>[USER-CONTENT]</string>
                <string>[NAME-APP]</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb[CODE]</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            <string>dynamiclinks1</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>[URL]</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>FacebookAppID</key>
    <string>[CODE]</string>
    <key>FacebookClientToken</key>
    <string>[CODE]</string>
    <key>FacebookDisplayName</key>
    <string>[NAME]</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>instagram-stories</string>
        <string>instagram</string>
        <string>facebook-stories</string>
        <string>facebook</string>
        <string>whatsapp</string>
        <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>fbauth2</string>
        <string>fbshareextension</string>
        <string>fb-messenger-share-api</string>
        <string>itms</string>
        <string>twitter</string>
        <string>tg</string>
    </array>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    <key>FacebookAutoLogAppEventsEnabled</key>
    <true/>
    <key>FacebookAdvertiserIDCollectionEnabled</key>
    <true/>
    <key>NSCalendarsUsageDescription</key>
    <string>[NAME] App needs access to the calendar in order to schedule a meditation reminder for you.</string>
    <key>NSCameraUsageDescription</key>
    <string>[NAME] App needs access to the camera in order for you to take a photo to upload.</string>
    <key>NSHealthShareUsageDescription</key>
    <string>[NAME] App would like to store the time you spend meditating to your Health app.</string>
    <key>NSHealthUpdateUsageDescription</key>
    <string>[NAME] App would like to store the time you spend meditating to your Health app.</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>[NAME] App needs access to the photo library in order for you to choose a photo to upload.</string>
    <key>NSPhotoLibraryAddUsageDescription</key>
    <string>[NAME] App needs access to the photo library.</string>
    <key>NSUserTrackingUsageDescription</key>
    <string>[NAME] App would like to track the effectiveness of online marketing campaigns across traffic sources.</string>
    <key>UIBackgroundModes</key>
    <array>
        <string>audio</string>
        <string>fetch</string>
        <string>remote-notification</string>
    </array>
    <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>branch_universal_link_domains</key>
    <array>
        <string>[NAME].app.link</string>
        <string>[NAME]-alternate.app.link</string>
        <string>[NAME].test-app.link</string>
        <string>[NAME]-alternate.test-app.link</string>
    </array>
    <key>branch_key</key>
    <string>[CODE-BRANCH-KEY]</string>
    <key>UIStatusBarHidden</key>
    <true/>
    <key>NSRemindersUsageDescription</key>
    <string>The app doesn't require access to your reminders.</string>
    <key>NSContactsUsageDescription</key>
    <string>The app doesn't require access to your contacts.</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>The app doesn't require access to the microphone.</string>
    <key>NSSpeechRecognitionUsageDescription</key>
    <string>The app doesn't require access to speech recognition.</string>
    <key>NSLocationUsageDescription</key>
    <string>The app doesn't require access to your location.</string>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>The app doesn't require access to your location.</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>The app doesn't require access to your location.</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>The app doesn't require access to your location.</string>
    <key>NSAppleMusicUsageDescription</key>
    <string>The app doesn't require access to the media library.</string>
    <key>kTCCServiceMediaLibrary</key>
    <string>The app doesn't require access to the media library.</string>
    <key>NSMotionUsageDescription</key>
    <string>The app doesn't require access to motion sensors.</string>
    <key>CADisableMinimumFrameDurationOnPhone</key>
    <true/>
</dict>
</plist>

AppDelegate.swift


import UIKit
import Flutter
import HealthKit
import Intents
import WidgetKit
import SwiftUI
import FBSDKCoreKit

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {

    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        if #available(iOS 10.0, *) {
            UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate

            let flutterViewController = self.window.rootViewController as! FlutterViewController

            var flutter_native_splash = 1
            UIApplication.shared.isStatusBarHidden = false

            GeneratedPluginRegistrant.register(with: self)

        }

        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }

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

        return true
    }

    override func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        return true
    }

}
darwin-morocho commented 2 years ago

@giovannilima262 the problem is your AppDelegate.swift you are overriding some methods used by this plugin to redirect after facebook login

You should remove

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

        return true
    }

    override func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        return true
    }

check https://github.com/darwin-morocho/flutter-facebook-auth/issues/261#issuecomment-1177246811

giovannilima262 commented 2 years ago

Thanks, it worked for me