-
Notifications
You must be signed in to change notification settings - Fork 4k
🐛 [firebase_messaging] Error when subscribing to topics: "Invalid registration response :'Error=INVALID_PARAMETERS'. It is missing 'token' field." #9874
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
Comments
Thanks for the report @downhamd Is this only happening on iOS simulator or physical device too ? |
I am facing this issue also, and I did as same as in #9822 but it still does not work. This happened to me after upgrading flutter from
Click me
Click me
|
Hi @darshankawar. I can confirm that this is only happening on the iOS emulator. On the Android emulator there is no error message after subscribing to topics. And push notifications work fine on physical devices for both iOS and Android. |
Thanks for the update @downhamd I tried the official plugin example and ran it on simulator with latest plugin versions and didn't get the issue. |
No problem @darshankawar , I have removed the dependence on provider and simplified the code:
|
Thanks for the update. I tried the same using plugin example and by subscribing to topic, I was able to successfully susbscribe it running on iOS simulator:
But looking at the frequency of such issues like this and also below, I am keeping this issue open and labeling for further insights from the team. |
/cc @russellwheatley |
tested using the following in // ignore_for_file: require_trailing_commas
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
class MyApp extends StatefulWidget {
MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
Future<void> requestMessagingPermission() async {
FirebaseMessaging messaging = FirebaseMessaging.instance;
NotificationSettings settings = await messaging.requestPermission(
alert: true,
announcement: false,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: true,
);
print('User granted permission: ${settings.authorizationStatus}');
if (settings.authorizationStatus == AuthorizationStatus.authorized) {
print('User granted notifiactions permission');
final token = await messaging.getToken();
print('Messaging token: $token');
//subscribe to topics
for (final topic in ['some', 'new', 'topics']) {
print('topic subscribing... $topic');
try {
await messaging
.subscribeToTopic(topic)
.then((value) => print('topic subscribed: $topic'));
} catch (e) {
print('subscription error: $e');
}
}
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Testing Something'),
),
body: ElevatedButton(
onPressed: () async {
await requestMessagingPermission();
},
child: const Text('press me'),
)),
);
}
}
Got the following console results:
flutter doctor:
There's something wrong with your setup. I'm guessing something to do with method swizzling. Read the documentation here to see if this is your issue. |
Hey @downhamd. 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! |
Since there haven't been any recent updates here, I am going to close this issue. @downhamd if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this. |
Bug report
Describe the bug
I am getting the following error when I try to subscribe to topics:
Here is my function which is meant to obtain permissions for push notifications, then gets the token and subscribes to a list of topics...
I am getting the same error in the console for every topic that is being looped through and subscribed to. The weird thing is that push notifications were working before, but now they don't seem to be.
I have tried updating Flutter to the latest version (3.3.7), I have tried updating both the Firebase Core package (2.1.1) and the Firebase messaging package to their latest versions (14.0.4) and I am still getting the error.
What is this
token
that is missing? ThesubscribeToTopic()
function only seems to take the topic name string. Am I missing something?I have looked around for answers and haven't found much, some say that it may be to do with an xCode update, that is a possibility I suppose. Some have said that it may be to do with leaving a small amount of time like 1 second between getting the token and subscribing to topics. Is there anything that could be pointing to those?
Similar and possibly related to this or this?
Thank you very much, any help will be greatly appreciated.
Steps to reproduce
Steps to reproduce the behavior:
firebase_messaging
plugin to your flutter projectExpected behavior
I expect to be able to loop through a list of topic names and be able to subscribe to each topic.
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
The text was updated successfully, but these errors were encountered: