【发布时间】:2021-06-26 20:40:51
【问题描述】:
我的通知正常,但我添加了一个主题,现在我收到此错误
Runner[1964:844150] [VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: PlatformException(Error 8, com.google.fcm, The operation couldn’t be completed. Cannot parse topic name: '/NEW'. Will not subscribe., null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159)
<asynchronous suspension>
2021-03-30 22:45:32.221182+0300 Runner[1964:844150] [VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: PlatformException(Error 8, com.google.fcm, The operation couldn’t be completed. Cannot parse topic name: '/NEW'. Will not subscribe., null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159)
<asynchronous suspension>
2021-03-30 22:45:32.222853+0300 Runner[1964:844140] 6.33.0 - [Firebase/Messaging][I-FCM002009] Cannot parse topic name: '/NEW'. Will not subscribe.
2021-03-30 22:45:32.223594+0300 Runner[1964:844140] 6.33.0 - [Firebase/Messaging][I-FCM002009] Cannot parse topic name: '/NEW'. Will not subscribe.
这是我接收通知的代码:
class PushNotificationService {
final FirebaseMessaging _fcm;
PushNotificationService(this._fcm);
Future initialise() async {
if (Platform.isIOS) {
_fcm.requestNotificationPermissions(IosNotificationSettings());
}
String token = await _fcm.getToken();
_fcm.subscribeToTopic('/NEW');
debugPrint("FirebaseMessaging token: $token");
_fcm.configure(
onMessage: (Map<String, dynamic> message) async {
debugPrint("onMessage: $message");
},
onLaunch: (Map<String, dynamic> message) async {
debugPrint("onLaunch: $message");
_serialiseAndNavigate(message);
},
onResume: (Map<String, dynamic> message) async {
debugPrint("onResume: $message");
_serialiseAndNavigate(message);
},
);
}
正如我上面所说,在我添加此行 _fcm.subscribeToTopic('/NEW'); 之前它工作正常,并且在 android 上它工作正常,我没有收到任何错误
【问题讨论】: