Jer*_*vil 6 apn apple-push-notifications ios flutter firebase-cloud-messaging
有人会问为什么当我尝试向 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' }
Run Code Online (Sandbox Code Playgroud)
它说我的注册令牌未注册。查看 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});
});
Run Code Online (Sandbox Code Playgroud)
我还遵循了 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)
}
}
Run Code Online (Sandbox Code Playgroud)
知道为什么我仍然收到此错误吗?
顺便说一句,它在 Android 上运行得很好
| 归档时间: |
|
| 查看次数: |
6143 次 |
| 最近记录: |