locked
Firebase Cloud Firestore doesn't work RRS feed

  • Question

  • User380588 posted

    Hi,

    I'm using Xamarin.Firebase.Firestore nugget package for to access my bbdd on firebase.

    When my bbdd has no rules, everyone can access it, it works perfectly. But when I add rules so that only authenticated users can make use of them, I get an error. It tells me that I don't have enough permissions. On iOS it works perfectly.

    Any ideas?

    Thank you

    Sunday, July 19, 2020 6:08 PM

Answers

  • User380588 posted

    Now, I tried this

    app = Firebase.FirebaseApp.InitializeApp(context);
    

    and it works

    I don't understand... without options or appname...

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, July 20, 2020 5:51 PM

All replies

  • User382871 posted

    when I add rules so that only authenticated users can make use of them ... don't have enough permissions. Did you face the error like PERMISSION_DENIED: Missing or insufficient permissions? Make sure to use the same FirebaseApp object as the database when creating FirebaseAuth. ... var app = Firebase.FirebaseApp.InitializeApp(this, options, "Firebase"); var auth = FirebaseAuth.GetInstance(app); var database = FirebaseFirestore.GetInstance(app);

    Refer to: https://github.com/xamarin/GooglePlayServicesComponents/issues/178#issuecomment-468926665

    Monday, July 20, 2020 9:21 AM
  • User380588 posted

    Hi @YelinZh ,

    Thanks for answering.

    Yes, I use the same FirebaseApp object.

    public static void Init (Android.Content.Context context)
    {
        if (app == null)
        {
            var baseOptions = Firebase.FirebaseOptions.FromResource(context);
            var options = new Firebase.FirebaseOptions.Builder(baseOptions).SetProjectId("project_id").Build();
            app = Firebase.FirebaseApp.InitializeApp(context, options, AppName);
        }
    }
    

    Then I use 'app' object for creating FirebaseFirestore and FirebaseAuth instances

    Monday, July 20, 2020 5:35 PM
  • User380588 posted

    Now, I tried this

    app = Firebase.FirebaseApp.InitializeApp(context);
    

    and it works

    I don't understand... without options or appname...

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, July 20, 2020 5:51 PM
  • User382871 posted

    Congrats! The initializeApp(Context context) method will initialize the default FirebaseApp instance. If you've solved the issue, please mark your solution as the answer. It'll help others who face the similar problem.

    Tuesday, July 21, 2020 6:36 AM