【问题标题】:Firebase Name: com.firebase.core Reason: Configuration fails. It may be caused by an invalid GOOGLE_APP_IDFirebase 名称:com.firebase.core 原因:配置失败。这可能是由无效的 GOOGLE_APP_ID 引起的
【发布时间】: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


    【解决方案1】:

    从 Firebase 控制台下载 GoogleService-Info.plist 时,提供的配置中确实缺少 GOOGLE_APP_ID 字段。查看此处找到的示例后

    https://github.com/HabibAli/FCM-Xamarin-Forms/blob/master/FCM/FCM/FCM.iOS/GoogleService-Info.plist

    我添加了缺少的属性,并且 Firebase.Core.App.Configure() 调用工作正常。

    【讨论】:

      猜你喜欢
      • 2017-10-16
      • 2020-10-28
      • 2020-01-26
      • 1970-01-01
      • 2012-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多