Xamarin iOS Firebase Cloud Messaging - 推送通知 - 无法发送带有设备令牌的测试消息

Xamarin iOS Firebase Cloud Messaging - Push Notifications - can not send test message with device token

Xamarin iOS Firebase 云消息传递 - 推送通知。我正在发送通知: 我可以为 android 设备(来自 https://console.firebase.google.com 的 "send test message")发送通知并且它有效。 Android 设备令牌如下所示:

dffplp_ekKY:APA91bEVk83i3ZAA-ZB7FQZ4nlwCCxhkMdEQIH4nOiuHI7nI50VZs4Ti4Gsm-gHxtwfb6OvkQSXNI0kls71Fch2bGT6nN3lIzmZ1x1uzizlTKO9PaEibUG02CR-dGVdu6vclid4l3aDY

在 iOS 在 AppDelegate.cs:

  public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
   {
        var thisToken = deviceToken.Description;
        var DeviceToken = Regex.Replace(deviceToken.ToString(), "[^0-9a-zA-Z]+", "");
   }

这个令牌是:

<e24cad44 37d26c68 6c3defad f3685749 70c0180e 56526ae4 8ceb9253 e280d7a9>

DeviceToken 是:

e24cad4437d26c686c3defadf368574970c0180e56526ae48ceb9253e280d7a9

现在我转到 https://console.firebase.google.com 并尝试通过设备令牌发送测试消息,但在真实设备上什么也没有出现。当我通过 Target -> bundleId 发送通知时,它可以在 iOS.

上完美运行

我读到这个: https://medium.com/@kevinle/correctly-capture-ios-13-device-token-in-xamarin-3d0fa390b71b 但实际上我正在针对 iOS SDK 12.1 进行编译,而真实设备是 iOS 13.3,因此新的更改(奇怪的设备令牌)不会影响我的代码。

问题是:当我尝试在 iOS(android 工作正常)或我的令牌格式错误或无效?

我认为你应该用这个方法注册令牌

[Export("messaging:didReceiveRegistrationToken:")]
public void DidReceiveRegistrationToken(Messaging messaging, string fcmToken)
{
    // Monitor token generation: To be notified whenever the token is updated.
    Console.WriteLine("Received token: " + fcmToken);
    // Handle here how your app is storing token locally or send it to server
    // Note: This callback is fired at each app startup and whenever a new token is generated.
}