【发布时间】:2023-03-26 07:08:01
【问题描述】:
我正在使用 Xamarin.Firebase.iOS.CloudMessaging v3.1.2 (nuget),但我间歇性地在 iPhone 上没有收到任何通知消息。
在我最近的测试中,从 Firebase 控制台发送消息:
- 消息 1:在 iPhone 和 Android 上收到
- 消息 2(重复 1): 仅适用于 Android
- 消息 3(1 的重复):仅 在 Android 上收到
- 消息 4(重复 1):仅收到 安卓
- 消息 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