flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

An error occurred while calling method Messaging#subscribeToTopic

Open vasuravada opened this issue 3 years ago • 36 comments

Bug report

FLTFirebaseMessaging: An error occurred while calling method Messaging#subscribeToTopic, errorOrNil => {
    NSLocalizedFailureReason = "No APNS token specified before fetching FCM Token";
}
10.6.0 - [FirebaseMessaging][I-FCM002022] APNS device token not set before retrieving FCM Token for Sender ID '459269486562'.Be sure to re-retrieve the FCM token once the APNS device token is set.
10.6.0 - [FirebaseMessaging][I-FCM002022] Declining request for FCM Token since no APNS Token specified
10.6.0 - [FirebaseMessaging][I-FCM002010] The subscription operation failed due to an error getting the FCM token: Error Domain=com.google.fcm Code=505 "No APNS token specified before fetching FCM Token" UserInfo={NSLocalizedFailureReason=No APNS token specified before fetching FCM Token}.
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: [firebase_messaging/unknown] An unknown error has occurred.
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:315:18)
<asynchronous suspension>
#2      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:518:43)
<asynchronous suspension>
#3      MethodChannelFirebaseMessaging.subscribeToTopic (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:367:7)
<asynchronous suspension>


vasuravada avatar Mar 20 '23 12:03 vasuravada

Same issue

nta-trongpq-2 avatar Mar 21 '23 04:03 nta-trongpq-2

@vasuravada See this for more details and further reference.

darshankawar avatar Mar 21 '23 10:03 darshankawar

Same issue, any temporary fix?

FLTFirebaseMessaging: An error occurred while calling method Messaging#getToken, errorOrNil => {
    NSLocalizedFailureReason = "No APNS token specified before fetching FCM Token";
}
10.6.0 - [FirebaseMessaging][I-FCM002022] APNS device token not set before retrieving FCM Token for Sender ID '402938966955'.Be sure to re-retrieve the FCM token once the APNS device token is set.
10.6.0 - [FirebaseMessaging][I-FCM002022] Declining request for FCM Token since no APNS Token specified
flutter: [firebase_messaging/unknown] An unknown error has occurred.

hinryd avatar Mar 24 '23 03:03 hinryd

Hello @darshankawar

Why did you remove the label that indicated this issue needed attention?

My app is not running on iOS 16.3.1 and this is the only error message that appears.

I understand that this problem needs maximum attention, since it was a change that started to break the application, which did not happen before.

thiagotalma avatar Mar 27 '23 02:03 thiagotalma

Hey @vasuravada. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Apr 05 '23 01:04 google-oss-bot

Hi @darshankawar I'm facing same issue , Any temporary solution I'm using the following version. firebase_messaging: ^14.4.0

BilalPervez avatar Apr 12 '23 17:04 BilalPervez

I was not able to recreate this, is there any chance someone can provide a repro sample for me to check out?

russellwheatley avatar Apr 18 '23 15:04 russellwheatley

For me, it happens in profile/release builds only. On debug it works fine.

dzab5 avatar Apr 19 '23 09:04 dzab5

I'm facing same issue , Any temporary solution I'm using the following version. firebase_messaging: ^14.4.1

nurbek-b avatar Apr 27 '23 06:04 nurbek-b

I'm facing same issue , Any temporary solution I'm using the following version. firebase_messaging: ^14.4.1

Please use the following previous version to solve this problem, firebase_messaging: ^13.1.0 Try this version for messaging.

BilalPervez avatar Apr 27 '23 10:04 BilalPervez

Everyone facing this issue, per https://github.com/firebase/flutterfire/issues/10625#issuecomment-1513348001, please provide us a complete code sample that triggers the reported error so that we can properly address this.

darshankawar avatar Apr 27 '23 10:04 darshankawar

Hey @vasuravada. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar May 08 '23 01:05 google-oss-bot

@russellwheatley This issue only occurs in the release mode of iOS.

firebase_core: ^2.7.1 firebase_messaging: ^14.2.6

When calling getToken(), the following error occurs. And sometimes getToken() works properly when the app is terminated and reopened, and sometimes it does not.

FLTFirebaseMessaging: An error occurred while calling method Messaging#getToken, errorOrNil => {
    NSLocalizedFailureReason = "No APNS token specified before fetching FCM Token";
}
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: [firebase_messaging/unknown] An unknown error has occurred.
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:315)
<asynchronous suspension>
#2      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:518)
<asynchronous suspension>
#3      MethodChannelFirebaseMessaging.getToken (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:224)
<asynchronous suspension>
#4      NotificationController.getDeviceToken (package:cornermarket_flutter/controller/notification_controller.dart:138)
<asynchronous suspension>

sample code is available for review on my GitHub

HanCharles avatar May 10 '23 11:05 HanCharles

(lldb) 2023-05-19 14:15:47.590497+0800 Runner[721:157451] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(35)] Using the Impeller rendering backend.
10.7.0 - [FirebaseCore][I-COR000005] No app has been configured yet.
no valid “aps-environment” entitlement string found for application
FLTFirebaseMessaging: An error occurred while calling method Messaging#getToken, errorOrNil => {
    NSLocalizedFailureReason = "No APNS token specified before fetching FCM Token";
}
10.7.0 - [FirebaseMessaging][I-FCM002022] Declining request for FCM Token since no APNS Token specified
10.7.0 - [FirebaseMessaging][I-FCM002022] APNS device token not set before retrieving FCM Token for Sender ID '332326302966'.Be sure to re-retrieve the FCM token once the APNS device token is set.
10.7.0 - [FirebaseMessaging][I-FCM002022] Declining request for FCM Token since no APNS Token specified

erlangparasu avatar May 19 '23 06:05 erlangparasu

(lldb) 2023-05-19 14:15:47.590497+0800 Runner[721:157451] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(35)] Using the Impeller rendering backend.
10.7.0 - [FirebaseCore][I-COR000005] No app has been configured yet.
no valid “aps-environment” entitlement string found for application
FLTFirebaseMessaging: An error occurred while calling method Messaging#getToken, errorOrNil => {
    NSLocalizedFailureReason = "No APNS token specified before fetching FCM Token";
}
10.7.0 - [FirebaseMessaging][I-FCM002022] Declining request for FCM Token since no APNS Token specified
10.7.0 - [FirebaseMessaging][I-FCM002022] APNS device token not set before retrieving FCM Token for Sender ID '332326302966'.Be sure to re-retrieve the FCM token once the APNS device token is set.
10.7.0 - [FirebaseMessaging][I-FCM002022] Declining request for FCM Token since no APNS Token specified

Please use the following previous version to solve this problem, firebase_messaging: ^13.1.0 Try this version for messaging.

@BilalPervez Thanks!

work by using:

firebase_core_platform_interface: 4.5.1
firebase_messaging: ^13.1.0

other refs: https://stackoverflow.com/a/74228013/7843462

erlangparasu avatar May 19 '23 06:05 erlangparasu

When you're seeing this exception occur, are you seeing the following line also logged out:

no valid “aps-environment” entitlement string found for application

Just wondering whether this exception occurs because perhaps you haven't enabled this capability in release mode? 🤔

russellwheatley avatar May 22 '23 14:05 russellwheatley

Hey @vasuravada. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Jun 01 '23 01:06 google-oss-bot

The problem only occurs in release mode. Only on newer versions of iOS (greater than 16.3). Testing on physical device, not tested on emulator. In debug mode the problem does not occur.

I still haven't found a solution :(

cc: @russellwheatley

pubspec.yaml

firebase_core: ^2.13.1
firebase_messaging: ^14.2.5
firebase_analytics: ^10.4.2
firebase_crashlytics: ^3.3.2
flutter doctor -v
[âś“] Flutter (Channel stable, 3.10.3, on macOS 13.4 22F66 darwin-x64, locale
    pt-BR)
    • Flutter version 3.10.3 on channel stable at
      /usr/local/Caskroom/flutter/3.10.2/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f92f44110e (19 hours ago), 2023-06-01 18:17:33 -0500
    • Engine revision 2a3401c9bb
    • Dart version 3.0.3
    • DevTools version 2.23.1

[âś“] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/talma/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Users/talma/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.1012163
      9/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)
    • 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
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[âś“] Android Studio (version 2022.2)
    • Android Studio at /Users/talma/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.1012163
      9/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.6b802.4-9586694)

[âś“] VS Code (version 1.78.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.66.0

[âś“] Connected device (3 available)
    • iPhone (mobile) • 00008020-000A5C9C3A03002E • ios            • iOS 16.5
      20F66
    • macOS (desktop) • macos                     • darwin-x64     • macOS 13.4
      22F66 darwin-x64
    • Chrome (web)    • chrome                    • web-javascript • Google
      Chrome 100.0.4896.88

[âś“] Network resources
    • All expected network resources are available.

• No issues found!
Log Xcode - Build Configuration: Release
2023-06-02 15:41:23.076404-0300 Runner[8719:612053] Metal GPU Frame Capture Enabled
2023-06-02 15:41:23.076528-0300 Runner[8719:612053] Metal API Validation Enabled
2023-06-02 15:41:23.232168-0300 Runner[8719:612053] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(35)] Using the Impeller rendering backend.
2023-06-02 15:41:23.244516-0300 Runner[8719:612053] Warning: Unable to create restoration in progress marker file
2023-06-02 15:41:23.248702-0300 Runner[8719:612296] 10.9.0 - [FirebaseCore][I-COR000005] No app has been configured yet.
2023-06-02 15:41:23.264563-0300 Runner[8719:612053] <SKPaymentQueue: 0x280839310>: No observers found that respond to "paymentQueue:shouldAddStorePayment:forProduct:", will not check for purchase intents
2023-06-02 15:41:23.664422-0300 Runner[8719:612297] 10.9.0 - [FirebaseAnalytics][I-ACS023007] Analytics v.10.9.0 started
2023-06-02 15:41:23.666048-0300 Runner[8719:612297] 10.9.0 - [FirebaseAnalytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2023-06-02 15:41:23.681051-0300 Runner[8719:612301] 10.9.0 - [FirebaseMessaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
2023-06-02 15:41:23.697289-0300 Runner[8719:612053] [Firebase/Crashlytics] Version 10.9.0
2023-06-02 15:41:23.895346-0300 Runner[8719:612304] fopen failed for data file: errno = 2 (No such file or directory)
2023-06-02 15:41:23.895418-0300 Runner[8719:612304] Errors found! Invalidating cache...
2023-06-02 15:41:23.922305-0300 Runner[8719:612053] FLTFirebaseMessaging: An error occurred while calling method Messaging#getToken, errorOrNil => {
    NSLocalizedFailureReason = "No APNS token specified before fetching FCM Token";
}
2023-06-02 15:41:24.059109-0300 Runner[8719:612302] 10.9.0 - [FirebaseMessaging][I-FCM002022] APNS device token not set before retrieving FCM Token for Sender ID '9800880020'.Be sure to re-retrieve the FCM token once the APNS device token is set.
2023-06-02 15:41:24.060706-0300 Runner[8719:612302] 10.9.0 - [FirebaseMessaging][I-FCM002022] Declining request for FCM Token since no APNS Token specified
2023-06-02 15:41:24.474949-0300 Runner[8719:612328] 10.9.0 - [FirebaseAnalytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2023-06-02 15:41:24.554334-0300 Runner[8719:612328] 10.9.0 - [FirebaseAnalytics][I-ACS023012] Analytics collection enabled
2023-06-02 15:41:24.554496-0300 Runner[8719:612328] 10.9.0 - [FirebaseAnalytics][I-ACS023220] Analytics screen reporting is enabled. Call Analytics.logEvent(AnalyticsEventScreenView, parameters: [...]) to log a screen view event. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO (boolean) in the Info.plist
2023-06-02 15:45:26.226451-0300 Runner[8719:614047] [connection] nw_read_request_report [C7] Receive failed with error "Operation timed out"
2023-06-02 15:45:26.228397-0300 Runner[8719:614047] [connection] nw_read_request_report [C7] Receive failed with error "Operation timed out"
2023-06-02 15:45:26.234060-0300 Runner[8719:614047] [] nw_endpoint_flow_fillout_data_transfer_snapshot copy_info() returned NULL

thiagotalma avatar Jun 02 '23 19:06 thiagotalma

Did you already add Push Notifications capability on each mode (Debug, Release, and Profile) ?

image

erlangparasu avatar Jun 02 '23 22:06 erlangparasu

The configuration is correct.

I realized that a probable reason is the method call right afterwards:

  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
  String? token = await FirebaseMessaging.instance.getToken();

thiagotalma avatar Jun 06 '23 19:06 thiagotalma