1

I'm trying to get the FCM token using the firebase_messaging: ^7.0.3 version. Getting the error getToken, error fetching instanceID: FCM token returns a null value.

  static final FirebaseMessaging _firebaseMessaging=FirebaseMessaging();
  static String token;


_firebaseMessaging.requestNotificationPermissions();
      _firebaseMessaging.configure();

      token=await _firebaseMessaging.getToken();
      String token2 = await _firebaseMessaging.getToken().then((String token) {
        assert(token != null);
        print(token);
        return token;
      });
      print(token2);
Ankur Shinde
  • 304
  • 4
  • 19
  • you're using a "then" and an "away" for the same method... you should be doing one OR the other. Have you tried fetching the token from the current logged user? – Mariano Zorrilla May 29 '21 at 15:50
  • I tried both ways one by one but they both returning null. Yes, I tried to fetch the token from the currently logged user. – Ankur Shinde May 30 '21 at 05:02

0 Answers0