【问题标题】:Can you use Firebase Auth and Firebase Analytics in the same Xamarin.IOS project?你可以在同一个 Xamarin.IOS 项目中使用 Firebase Auth 和 Firebase Analytics 吗?
【发布时间】:2019-04-15 13:54:15
【问题描述】:

我正在开发一个集成了 Firebase 身份验证的 Xamarin.Forms 应用。我已经为 Android 和 iOS 设置了依赖服务,以便在出现提示时创建新用户。 Android 依赖项工作正常,但每当我在我的 iOS 依赖项中调用任何“Auth”方法时,应用程序在启动时崩溃,并从我的委托文件中的“Firebase.Core.App.Configure()”行抛出以下错误:

Foundation.MonoTouchException 已被抛出

Objective-C 抛出异常。名称:NSInvalidArgumentException 原因: -[FIRApp setGetTokenImplementation:]:unrecognized selector sent to instance 0x282d3d1a0

...后面是一英里长的堆栈跟踪

我当前的 iOS 依赖代码如下:

using System;
using Xamarin.Forms;
using ActNearMe; //name of my app
using Firebase.Auth;
using Firebase.InstanceID;
using Firebase.Core;
using System.Collections.Specialized;
using System.Net;
using System.Threading.Tasks;

[assembly: Dependency(typeof(IFirebaseInterface))]
namespace ActNearMe.iOS
{
    public class FirebaseInterface : IFirebaseInterface
    {
    WebClient client = new WebClient();
    NameValueCollection sendingData;

    public void CreateNewUser(string email, string password, NameValueCollection userData)
    {
        //sendingData = userData;

        //Anytime I call anything with Auth here, the app won't even load.
        Console.WriteLine(Auth.CurrentVersion);


        //Auth.DefaultInstance.CreateUser(email, password,(authResult, error) => { 

        /*client.UploadValuesCompleted += (sender, e) =>
        {

            Console.WriteLine("it's done!");


        };
        client.UploadValuesAsync(new Uri("http://www.cvx4u.com/anm_web_services/create_user.php"), sendingData);
        */

       //});

    }




    }

}

这是我的错误日志:

2019-04-15 10:18:53.724 ActNearMe.iOS[6964:1670900] +[FIRApp    registerAsConfigurable:]: unrecognized selector sent to class 0x1060d1bb8
2019-04-15 10:18:53.724 ActNearMe.iOS[6964:1670900] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[FIRApp registerAsConfigurable:]: unrecognized selector sent to class 0x1060d1bb8'
*** First throw call stack:
(0x22401c518 0x2231f79f8 0x223f3e2c4 0x224021d60 0x2240239fc 0x2231f9ffc 0x2231fbe54 0x106626390 0x106638314 0x106637370 0x10663742c 0x1066266d8 0x10662b2a0 0x106625044)
libc++abi.dylib: terminating with uncaught exception of type NSException
Application 'com.russjowell.actnearme' terminated.
Launched application 'com.russjowell.actnearme' on 'iPhone (2)' with pid 6964

更新 所以我一直在尝试打开和关闭一些东西,省略某些代码行等。我还在我的应用程序中使用 Firebase Analytics,当我从我的 Xamarin.iOS 项目中删除 Firebase iOS NuGet Analytics 包时,一切正常,但是当你同时使用 Analytics 和 Auth 包时,崩溃会继续。所以我想我的新问题是: 是否可以在同一个项目中同时使用 Firebase iOS Auth 和 Firebase iOS Analytics?任何见解都会有所帮助。

【问题讨论】:

    标签: firebase xamarin xamarin.ios firebase-authentication


    【解决方案1】:

    问题在于 NuGet 包。

    该内部方法存在于 v5.1.8 中,但不存在于 v5.2.0 中。

    现在,请降级到 5.1.8

    https://github.com/xamarin/GoogleApisForiOSComponents/issues/245

    【讨论】:

      【解决方案2】:

      错误表明应该处理消息的对象已被释放。

      这可能是绑定或向 Firebase 提供回调的方式存在问题。

      仅从您拥有的 sn-p 无法诊断问题,因此快速解决方法是执行以下操作:

      将 C# 对象传递给 Firebase 的任何对象都可能需要保存在静态全局变量中。这将确保它不会被丢弃。

      【讨论】:

      • 如果有帮助,只要我在我的 iOS 依赖项中调用“Auth”下的任何内容(例如,只是“Console.WriteLine(Auth.DefaultInstance.Description);”,我就会遇到这些问题。但是,一旦我删除对 Auth 的调用,问题就解决了。我需要进行 Auth 调用 b/c 我正在使用 Firebase 进行身份验证。
      猜你喜欢
      • 2018-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-21
      • 2021-10-31
      • 2017-10-03
      相关资源
      最近更新 更多