首页 > 解决方案 > Xamarin Firebase Cloud 消息间歇性不起作用

问题描述

我正在使用Xamarin.Firebase.iOS.CloudMessaging v3.1.2 (nuget) 并且间歇性地我没有在 iPhone 上收到任何通知消息。

在我最新的测试中,从 Firebase 控制台发送消息:

  1. 消息 1:在iPhone和 Android上收到
  2. 消息 2(1 的重复):仅在 Android 上收到
  3. 消息 3(1 的重复):仅在 Android 上收到
  4. 消息 4(1 的重复):仅在 Android 上收到
  5. 消息 5(新消息):仅在 Android 上收到

由于这间歇性地工作,我认为实施应该没问题?有谁知道可以解释这种行为的任何问题?

private void RegisterForPushNotifications() {
    // Register your app for remote notifications.
    if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) {
        // iOS 10 or later
        var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
        UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) => {
            //Console.WriteLine(granted);
        });

        // For iOS 10 display notification (sent via APNS)
        UNUserNotificationCenter.Current.Delegate = this;

        // For iOS 10 data message (sent via FCM)
        Messaging.SharedInstance.Delegate = this;
    }
    else {
        // iOS 9 or before
        var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
        var settings = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
        UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
    }

    UIApplication.SharedApplication.RegisterForRemoteNotifications();
}

如果有人可以帮助我对此有所了解,将不胜感激!

标签: firebasexamarinxamarin.formsxamarin.iosfirebase-cloud-messaging

解决方案


这似乎是 Xamarin.iOS.CloudMessaging 中的一个错误;当降级 3.1.2 -> 2.0.8 时,一切又开始工作了。

我已经向 github 存储库发布了一个问题。


推荐阅读