Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FCM] get token always returns null #1888

Closed
craigbennett1981 opened this issue Jan 28, 2020 · 1 comment
Closed

[FCM] get token always returns null #1888

craigbennett1981 opened this issue Jan 28, 2020 · 1 comment
Labels
type: bug Something isn't working

Comments

@craigbennett1981
Copy link

craigbennett1981 commented Jan 28, 2020

I am trying to use firebase cloud messaging but when I try get the users token, FCM always returns null. I have tries this on my own project which has other firebase services working and also on the example in this project (https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_messaging/example). Below is the stack trace and a flutter doctor output. Any advice on how to debug this would be much appreciated.

To Reproduce
Open example project above and run and FCM token is returned null

Expected behavior
FCM token should be returned

Additional context

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Checking the license for package Android SDK Build-Tools 28.0.3 in C:\Users\craig\AppData\Local\Android\Sdk\licenses
License for package Android SDK Build-Tools 28.0.3 accepted.
Preparing "Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)".
"Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" ready.
Installing Android SDK Build-Tools 28.0.3 in C:\Users\craig\AppData\Local\Android\Sdk\build-tools\28.0.3
"Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" complete.
"Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" finished.
Checking the license for package Android SDK Platform 28 in C:\Users\craig\AppData\Local\Android\Sdk\licenses
License for package Android SDK Platform 28 accepted.
Preparing "Install Android SDK Platform 28 (revision: 6)".
"Install Android SDK Platform 28 (revision: 6)" ready.
Installing Android SDK Platform 28 in C:\Users\craig\AppData\Local\Android\Sdk\platforms\android-28
"Install Android SDK Platform 28 (revision: 6)" complete.
"Install Android SDK Platform 28 (revision: 6)" finished.
√ Built build\app\outputs\apk\debug\app-debug.apk.
E/flutter ( 7115): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: 'package:firebase_messaging_example/main.dart': Failed assertion: line 162 pos 14: 'token != null': is not true.
 [38;5;244mE/flutter ( 7115): #0      _AssertionError._doThrowNew  (dart:core-patch/errors_patch.dart:42:39) [39;49m
 [38;5;244mE/flutter ( 7115): #1      _AssertionError._throwNew  (dart:core-patch/errors_patch.dart:38:5) [39;49m
 [38;5;248mE/flutter ( 7115): #2      _PushMessagingExampleState.initState.<anonymous closure> [39;49m
 [38;5;244mE/flutter ( 7115): #3      _rootRunUnary  (dart:async/zone.dart:1134:38) [39;49m
 [38;5;244mE/flutter ( 7115): #4      _CustomZone.runUnary  (dart:async/zone.dart:1031:19) [39;49m
 [38;5;244mE/flutter ( 7115): #5      _FutureListener.handleValue  (dart:async/future_impl.dart:139:18) [39;49m
 [38;5;244mE/flutter ( 7115): #6      Future._propagateToListeners.handleValueCallback  (dart:async/future_impl.dart:680:45) [39;49m
 [38;5;244mE/flutter ( 7115): #7      Future._propagateToListeners  (dart:async/future_impl.dart:709:32) [39;49m
 [38;5;244mE/flutter ( 7115): #8      Future._completeWithValue  (dart:async/future_impl.dart:524:5) [39;49m
 [38;5;244mE/flutter ( 7115): #9      _AsyncAwaitCompleter.complete  (dart:async-patch/async_patch.dart:32:15) [39;49m
 [38;5;244mE/flutter ( 7115): #10     _completeOnAsyncReturn  (dart:async-patch/async_patch.dart:290:13) [39;49m
E/flutter ( 7115): #11     FirebaseMessaging.getToken (package:firebase_messaging/firebase_messaging.dart)
E/flutter ( 7115): <asynchronous suspension>
 [38;5;248mE/flutter ( 7115): #12     _PushMessagingExampleState.initState [39;49m
 [38;5;244mE/flutter ( 7115): #13     StatefulElement._firstBuild [39;49m
 [38;5;244mE/flutter ( 7115): #14     ComponentElement.mount [39;49m
 [38;5;244mE/flutter ( 7115): #15     Element.inflateWidget [39;49m
 [38;5;244mE/flutter ( 7115): #16     Element.updateChild [39;49m
 [38;5;244mE/flutter ( 7115): #17     SingleChildRenderObjectElement.mount [39;49m
 [38;5;244mE/flutter ( 7115): #18     Element.inflateWidget [39;49m
 [38;5;244mE/flutter ( 7115): #19     Element.updateChild [39;49m
 [38;5;244mE/flutter ( 7115): #20     ComponentElement.performRebuild [39;49m
 [38;5;244mE/flutter ( 7115): #21     Element.rebuild [39;49m
 [38;5;244mE/flutter ( 7115): #22     ComponentElement._firstBuild [39;49m
 [38;5;244mE/flutter ( 7115): #23     ComponentElement.mount [39;49m
 [38;5;244mE/flutter ( 7115): #24     Element.inflateWidget [39;49m
 [38;5;244mE/flutter ( 7115): #25     Element.updateChild [39;49m
 [38;5;244mE/flutter ( 7115): #26     SingleChildRenderObjectElement.mount [39;49m
 [38;5;244mE/flutter ( 7115): #27     Element.inflateWidget [39;49m
 [38;5;244mE/flutter ( 7115): #28     Element.updateChild [39;49m
 [38;5;244mE/flutter ( 7115): #29     SingleChildRenderObjectElement.mount [39;49m
 [38;5;244mE/flutter ( 7115): #30     Element.inflateWidget [39;49m
 [38;5;244mE/flutter ( 7115): #31     Element.updateChild [39;49m
 [38;5;244mE/flutter ( 7115): #32     ComponentElement.performRebuild [39;49m
 [38;5;244mE/flutter ( 7115): #33     Element.rebuild [39;49m
 [38;5;244mE/flutter ( 7115): #34     ComponentElement._firstBuild [39;49m
 [38;5;244mE/flutter ( 7115): #35     StatefulElement._firstBuild [39;49m
 [38;5;244mE/flutter ( 7115): #36     ComponentElement.mount [39;49m
 [38;5;244mE/flutter ( 7115): #37     Element.inflateWidget [39;49m
 [38;5;244mE/flutter ( 7115): #38     Element.updateChild [39;49m
 [38;5;244mE/flutter ( 7115): #39     SingleChildRenderObjectElement.mount [39;49m
 [38;5;244mE/flutter ( 7115): #40     Element.inflateWidget [39;49m
 [38;5;244mE/flutter ( 7115): #41     Element.updateChild [39;49m
 [38;5;244mE/flutter ( 7115): #42     SingleChildRenderObjectElement.mount [39;49m
 [38;5;244mE/flutter ( 7115): #43     Element.inflateWidget [39;49m
 [38;5;244mE/flutter ( 7115): #44     Element.updateChild [39;49m
E/flutter ( 7115): #45     ComponentElement.performRebuild (package:flutter/src/widgets/fr

flutter doctor -v

[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.18362.592], locale en-SG)
    • Flutter version 1.12.13+hotfix.5 at c:\flutter
    • Framework revision 27321ebbad (7 weeks ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\craig\AppData\Local\Android\Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = C:\Users\craig\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    • All Android licenses accepted.

[√] Android Studio (version 3.5)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] VS Code, 64-bit edition (version 1.41.1)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.7.1

[√] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

• No issues found!
@craigbennett1981 craigbennett1981 added the type: bug Something isn't working label Jan 28, 2020
@demon-zhonglin
Copy link

demon-zhonglin commented Apr 24, 2020

I also have this problem, how do you solve it?
Resolved, network cause

@firebase firebase locked and limited conversation to collaborators Aug 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants