【问题标题】:Xamarin Firebase Cloud messages intermittently not workingXamarin Firebase Cloud 消息间歇性不起作用
【发布时间】:2023-03-26 07:08:01
【问题描述】:

我正在使用 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):仅收到 安卓
  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();
}

如果有人能帮助我阐明这一点,将不胜感激!

【问题讨论】:

  • 您从哪里发送通知?
  • @r15 为了测试,我使用 Firebase 控制台发送消息
  • 在发布模式下生成apk并尝试。调试模式不是那么准确。
  • 这是发布模式,很遗憾
  • 您如何收集token 发送通知

标签: firebase xamarin xamarin.forms xamarin.ios firebase-cloud-messaging


【解决方案1】:

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

我已将问题发布到 github 存储库。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-27
    • 2021-09-06
    • 1970-01-01
    • 2020-07-31
    • 1970-01-01
    相关资源
    最近更新 更多