darwin-morocho / flutter-facebook-auth

A flutter plugin to add login with facebook in your flutter app
194 stars 129 forks source link

error : User has cancelled login with facebook #287

Closed jackie-maxx closed 1 year ago

jackie-maxx commented 1 year ago

What version are you using?

4.1.1+1

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

macOS 10.15.7

What platforms are you seeing the problem on?

Android

pubspec.yaml

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

environment:
  sdk: ">=2.16.2 <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_screenutil: ^5.0.0+2
  flutter_svg: any
  loading_overlay: ^0.2.1
  cupertino_icons: ^1.0.2
  timeago: ^3.2.2
  intl: ^0.17.0
  sqflite: ^2.0.2
  json_annotation: ^4.5.0
  package_info_plus: ^1.4.2
  easy_localization: ^3.0.0
  connectivity_plus: ^2.3.4
  pinput: ^2.2.11
  path_provider: ^2.0.11
  settings_ui: ^2.0.2
  maxx_sunmi_printer: ^0.0.4
  device_info_plus: ^4.0.0
  esc_pos_printer: ^4.1.0
  esc_pos_utils: ^1.1.0
  date_range_picker: ^1.0.7
  fl_chart: ^0.55.0
  data_table_2: ^2.2.1
  share_files_and_screenshot_widgets_plus: ^1.0.4
  rxdart: ^0.27.5
  flutter_spinkit: ^5.1.0
  mobile_scanner: ^1.1.2
  expand_tap_area: ^1.1.0
  fluttertoast: ^8.0.9
  flutter_multi_formatter: ^2.7.4
  flutter_slidable: ^1.3.2
  image_cropper: ^3.0.0
  image_picker: ^0.8.5+3
  dotted_border: ^2.0.0+2
  dio: ^4.0.6
  flutter_facebook_auth: ^4.4.1+1
  flutter_widget_from_html: ^0.8.5
  eventsource: ^0.4.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner: ^2.1.8
  json_serializable: ^6.0.0
  flutter_native_splash: ^2.1.5
  flutter_launcher_icons: ^0.9.3
  flutter_lints: ^1.0.0

flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/logo/logo.png"
  adaptive_icon_background: "#cca62c"
  adaptive_icon_foreground: "assets/logo/logo_foreground.png"

flutter_native_splash:
  android: true
  ios: true
  web: true
  color: "#ffffff"
  image: "assets/splash/splash.png"
  android_12:
    image: "assets/splash/splash.png"

# 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.
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/translations/
    - assets/images/no_image.png
    - assets/images/no_data.png
    - assets/images/product_no_image.png
    - assets/images/
    - assets/icons/
    - assets/images/language/khmer.png
    - assets/images/language/english.png
    - assets/images/company_icon.png
       # --- Image message --- 
    - assets/image_message/close.png
    - assets/image_message/icon_error.png
    - assets/image_message/icon_info.png
    - assets/image_message/icon_success.png
    - assets/image_message/icon_warning.png  
    - assets/image_message/icon_question.png
      # --- icon ---  
    - assets/icons/user.png
    - assets/icons/logo.png
    - assets/icons/icon_receive_money.png
    - assets/icons/icon_customer.png
    - assets/icons/icon_barcode.png
    - assets/icons/icon_shoping_card.png
    - assets/icons/icon_transaction_report.png
    - assets/icons/USD.png
    - assets/icons/KHR.png
    - assets/icons/BTH.png
       # --- Image Sticker --- 
    - assets/sticker/no_data.png
    - assets/sticker/change_password.png
    - assets/sticker/welcom.png
    - assets/sticker/system.png
    - assets/sticker/register.png
    - assets/sticker/login_pin_code.png
       # --- table ---- 
    - assets/tables/application_setting.sql
    - assets/tables/cash_bank_account.sql
    - assets/tables/company_information.sql
    - assets/tables/currency.sql
    - assets/tables/customer_address.sql
    - assets/tables/customer_discount_group.sql
    - assets/tables/customer_group.sql
    - assets/tables/customer_price_group.sql
    - assets/tables/customer.sql
    - assets/tables/fb_live_setting.sql
    - assets/tables/fb_page_live_comment.sql
    - assets/tables/inventory_posting_group.sql
    - assets/tables/location.sql
    - assets/tables/master_data_synch_log.sql
    - assets/tables/pos_no_series_line.sql
    - assets/tables/payment_method.sql
    - assets/tables/payment_term.sql
    - assets/tables/product_category.sql
    - assets/tables/product_class.sql
    - assets/tables/product_family.sql
    - assets/tables/pos_menu_group.sql
    - assets/tables/pos_menu_item.sql
    - assets/tables/pos_receipt.sql
    - assets/tables/product_discount_group.sql
    - assets/tables/product_group.sql
    - assets/tables/product_posting_group.sql
    - assets/tables/product_sales_line_discount.sql
    - assets/tables/product_sales_line_prices.sql
    - assets/tables/product_unit_of_measure.sql 
    - assets/tables/product.sql
    - assets/tables/receivable.sql
    - assets/tables/sales_line.sql
    - assets/tables/sales.sql
    - assets/tables/service.sql
    - assets/tables/setting.sql
    - assets/tables/store.sql
    - assets/tables/tax_posting_setup.sql
    - assets/tables/trade_promotion_code.sql
    - assets/tables/unit_of_measure.sql
    - assets/tables/user_setup.sql
    # --- data init ---
    - assets/data/master_data.sql
    - assets/data/customer.sql
    - assets/data/pos_no_series_line.sql
    - assets/data/payment_method.sql
    - assets/data/payment_term.sql
    - assets/data/product_group.sql
    - assets/data/product_unit_of_measure.sql
    - assets/data/product.sql
    - assets/data/setting.sql
    - assets/data/store.sql
    - assets/data/unit_of_measure.sql
    # --- script update --- 
    - assets/script_update/

  #   - 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: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     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

error : User has cancelled login with facebook

when i testing in emulator (android) it run normal and when i using on real device it show error like below.

Expected Behavior

when login Show Facebook login dialog

To Reproduce

static Future fbLogin() async { try { final LoginResult result = await FacebookAuth.instance.login();

  if (result.status == LoginStatus.success) {
    final userData = await FacebookAuth.instance.getUserData();

    dynamic data = {
      "access_token": result.accessToken,
      "user_data": userData,
    };
    return ReturnMsg(status: StatusMsg.success, message: LocaleKeys.success.tr(), object: data);
  } else {
    return ReturnMsg(status: StatusMsg.warning, message: "[fbLogin]\n${result.message.toString()}");
  }
} catch (ex) {
  return ReturnMsg(status: StatusMsg.failed, message: "[fbLogin]\n${ex.toString()}");
}

}

Relevant log output

No response

flutter doctor -v

[✓] Flutter (Channel stable, 2.10.5, on Mac OS X 10.15.7 19H2026 darwin-x64,
    locale en-KH)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 12.4)
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.71.2)
[✓] Connected device (1 available)
[✓] HTTP Host Availability

Info.plist (iOS)

No response

Podfile (iOS)

No response

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.maxx4business.pos">

    <queries>
        <provider android:authorities="com.facebook.katana.provider.PlatformProvider" />
    </queries>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

   <application
        android:label="Moow App"
        android:name="${applicationName}"
        android:icon="@mipmap/launcher_icon">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

               <!-- facebook configs -->
               <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
               <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>

          <activity android:name="com.facebook.FacebookActivity"
            android:configChanges=
                    "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name" />
          <activity
                android:name="com.facebook.CustomTabActivity"
                android:exported="true">
                <intent-filter>
                    <action android:name="android.intent.action.VIEW" />
                    <category android:name="android.intent.category.DEFAULT" />
                    <category android:name="android.intent.category.BROWSABLE" />
                    <data android:scheme="@string/fb_login_protocol_scheme" />
                </intent-filter>
          </activity>

        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
    </application>
</manifest>

MainActivity.java

No response

MainActivity.kt

No response

index.html

No response

Info.plist (macOS)

No response

darwin-morocho commented 1 year ago

@jackie-maxx it seems that you are using the last version of this plugin so you need to update your AndroidManifest

example

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="app.meedu.flutter_facebook_auth_example">
    <uses-permission android:name="android.permission.INTERNET" />
    <application
       android:name="${applicationName}"
       android:icon="@mipmap/ic_launcher"
       android:label="facebook auth">

       <meta-data
           android:name="com.facebook.sdk.ApplicationId"
           android:value="@string/facebook_app_id" />
       <meta-data 
           android:name="com.facebook.sdk.ClientToken" 
           android:value="@string/facebook_client_token"/>

        <activity
           android:name=".MainActivity"
           android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
           android:hardwareAccelerated="true"
           android:launchMode="singleTop"
           android:theme="@style/LaunchTheme"
           android:exported="true"
           android:windowSoftInputMode="adjustResize">
           <meta-data
               android:name="io.flutter.embedding.android.NormalTheme"
               android:resource="@style/NormalTheme" />
           <meta-data
               android:name="io.flutter.embedding.android.SplashScreenDrawable"
               android:resource="@drawable/launch_background" />
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
       </activity>
       <meta-data
           android:name="flutterEmbedding"
           android:value="2" />
    </application>
</manifest>

you must remove

   <activity android:name="com.facebook.FacebookActivity"
            android:configChanges=
                    "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name" />
          <activity
                android:name="com.facebook.CustomTabActivity"
                android:exported="true">
                <intent-filter>
                    <action android:name="android.intent.action.VIEW" />
                    <category android:name="android.intent.category.DEFAULT" />
                    <category android:name="android.intent.category.BROWSABLE" />
                    <data android:scheme="@string/fb_login_protocol_scheme" />
                </intent-filter>
          </activity>

Also if your app is still in developing mode in your facebook console you only can use test accounts or use the facebook account witch is the owner of the app in the facebook developer console