TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
211 stars 49 forks source link

Added region into functions. #293

Closed robertmaxted closed 5 months ago

robertmaxted commented 5 months ago

Added overload for region specification (functions). Default will remain as "us-central1".

robertmaxted commented 5 months ago

@AdamEssenmacher @TobiasBuchholz - ready for review.

robertmaxted commented 5 months ago

I don't think this compiles? CloudFunctions.GetInstance() isn't a method on the iOS side.

@AdamEssenmacher Sorry about that oversight. It should compile as expected now. I am unable to test on my environment, having lots of issue with MS build and workloads. I do not see why it wouldn't compile now.

We can then init like this:

private static MauiAppBuilder RegisterFirebaseServices(this MauiAppBuilder builder) { builder.ConfigureLifecycleEvents(events => {

if IOS

    events.AddiOS(iOS => iOS.WillFinishLaunching((_,__) =>
    {
        CrossFirebase.Initialize(); // General Firebase initialization
        CrossFirebaseFunctions.Initialize("europe-west2"); // Set specific region for Functions
        return false;
    }));

elif ANDROID

    events.AddAndroid(android => android.OnCreate((activity, _) =>
    {
        CrossFirebase.Initialize(activity); // General Firebase initialization
        CrossFirebaseFunctions.Initialize("europe-west2"); // Set specific region for Functions
    }));

endif

});

builder.Services.AddSingleton(_ => CrossFirebaseAuth.Current);
return builder;

}

I think..?

P.S - thanks for your time.

AdamEssenmacher commented 5 months ago

Addresses #292