【发布时间】:2018-07-20 16:46:41
【问题描述】:
按照 https://components.xamarin.com/gettingstarted/firebaseioscloudmessaging 上的 firebase 指令集入门中的说明调用 Firebase.Core.App.Configure() 导致下面指出的错误。我已经看到了对此的其他答案,但它们似乎专门与 cordova 和 GoogleServices-Info.plist 已损坏或未复制到特定文件夹有关。
错误
名称:com.firebase.core 原因:配置失败。可能是由于 通过 GoogleService-Info.plist 中的无效 GOOGLE_APP_ID 或在 自定义选项。
调用 Firebase.Core.App.Configure() 时出错;
private void RegisterForPushNotifications()
{
if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
{
// iOS 10
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;
}
else
{
// iOS 9 <=
var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
var settings = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
}
UIApplication.SharedApplication.RegisterForRemoteNotifications();
// Firebase component initialize
Firebase.Core.App.Configure();
Firebase.InstanceID.InstanceId.Notifications.ObserveTokenRefresh((sender, e) =>
{
var newToken = Firebase.InstanceID.InstanceId.SharedInstance.Token;
// if you want to send notification per user, use this token
//TODO need WS calls to store this token in the user table
System.Diagnostics.Debug.WriteLine(newToken);
connectFCM();
});
}
【问题讨论】:
标签: firebase xamarin xamarin.ios