有人会是为什么我尝试向Iphone物理设备发送通知时出现此错误的原因吗?
Error sending message { Error: Requested entity was not found.
at FirebaseMessagingError.FirebaseError [as constructor] (/srv/node_modules/firebase-admin/lib/utils/error.js:42:28)
at FirebaseMessagingError.PrefixedFirebaseError [as constructor] (/srv/node_modules/firebase-admin/lib/utils/error.js:88:28)
at new FirebaseMessagingError (/srv/node_modules/firebase-admin/lib/utils/error.js:254:16)
at Function.FirebaseMessagingError.fromServerError (/srv/node_modules/firebase-admin/lib/utils/error.js:287:16)
at Object.createFirebaseError (/srv/node_modules/firebase-admin/lib/messaging/messaging-errors.js:34:47)
at /srv/node_modules/firebase-admin/lib/messaging/messaging-api-request.js:76:42
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
errorInfo:
{ code: 'messaging/registration-token-not-registered',
message: 'Requested entity was not found.' },
codePrefix: 'messaging' }
是说我的注册令牌未注册。 在查看了Firebase文档后,我看到了: https://firebase.google.com/docs/cloud-messaging/send-message#admin_sdk_error_reference
邮件/注册令牌未注册:
未注册提供的注册令牌。出于多种原因,可以取消先前有效的注册令牌,包括:
对于所有这些情况,请删除此注册令牌并停止使用它发送消息。
但是我觉得我已经满足了所有要求(APNS已经配置并添加到Firebase控制台中) (已经在我的Apple开发者帐户的证书,标识符和配置文件中创建)
我什至添加了要求用户许可的代码(当我在设备上对其进行测试时,它也可以工作)
getIOSPermission() {
_firebaseMessaging.requestNotificationPermissions(
IosNotificationSettings(alert: true, badge: true, sound: true));
_firebaseMessaging.onIosSettingsRegistered.listen((settings) {
print("Settings registered:$settings");
});
}
void requestIOSPermissions() {
flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>()
?.requestPermissions(
alert: true,
badge: true,
sound: true,
);
}
if (Platform.isIOS) {
getIOSPermission();
requestIOSPermissions();
}
_firebaseMessaging.getToken().then((token) {
print("Firebase Messaging Token: $token\n");
usersRef
.document(firebaseUser.uid)
.updateData({"androidNotificationToken": token});
});
我还遵循了FCM软件包自述文件中指定的有关IOS集成的所有步骤。 https://pub.dev/packages/firebase_messaging
这是我的AppDelegate.swift代码:
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
知道为什么我仍然会收到此错误吗?
顺便说一句,它适用于Android
答案 0 :(得分:0)
当尝试发送的 FCM 令牌不再注册时,会发生此错误,由 "messaging/registration-token-not-registered"
错误代码给出。您可以尝试从用户的令牌中删除此令牌,看看它是否有效。