Support for Google Firebase

At the Latest Google I/O they announced that Firebase is the recommended analytics solution for mobile apps and is encouraging people to migrate from Google Analytics. Will (and when?) Xamarin provide a Firebase component?

Thanks.

«1

Posts

  • stvansolanostvansolano UMInsider, University ✭✭✭

    Hello @RainerMager,

    You can actually perform calls to Firebase via REST calls which you can call using standard .Net classes and even with ModernHttpClient library which is a xamarin.plugin. Have you give it a try?

  • stvansolanostvansolano UMInsider, University ✭✭✭

    I can share some code examples of it if someone is interested in abstract it and make it a shared library in case it may help. Let me know.

  • RonaldMillerRonaldMiller USMember

    @stvansolano said:
    I can share some code examples of it if someone is interested in abstract it and make it a shared library in case it may help. Let me know.

    Esteban,

    How do you manage realtime sync using their REST calls?

  • rmaciasrmacias USBeta, University ✭✭✭✭✭

    For starters, the folks at Google/Firebase will have to build a .NET compatible SDK. Preferably using a PCL (Bait & Switch) technique so that it can easily be used in a Cross Platform architecture. Right now, they don't have one:

    https://firebase.google.com/docs/libraries/

    Google has historically been hostile to anything .NET/Microsoft, so I wouldn't count on them as making this a top priority, which I find hypocritical on their part about "embracing openness". So until they provide this to developers, not much Xamarin can do besides creating bindings for the iOS/Android SDKs.

    Even so, Bindings for the iOS/Android SDKs would only be (in my opinion) a partial solution as I would rather have all business logic and data layer defined in my PCL. Depending how different the paradigms are in each platform SDK, it might be possible using Shared Libraries or even use Dependency Injection. But that can be limiting depending on what the SDK expects.

  • rmaciasrmacias USBeta, University ✭✭✭✭✭

    And of course, here it is from the horse's mouth:

    https://groups.google.com/forum/#!searchin/firebase-talk/.net/firebase-talk/0S4LdU6orZA/tVNYifvdFQAJ

    Hi Guys,

    .Net support isn't really on the radar, sorry. Your best bet here is to utilize the REST API.

    I'll write down your feedback and make sure it gets to the appropriate folks on the team. Really appreciate you posting this to let us know!

    ☼, Kato

  • CarolaFichtnerCarolaFichtner DEBeta ✭✭

    Found this one: http://stackoverflow.com/questions/37420600/can-should-i-use-firebase-with-ionic-2-or-xamarin,
    comment from Jon Douglas: "Bindings are being created as we speak for Xamarin."

  • CarolaFichtnerCarolaFichtner DEBeta ✭✭

    there seems to be something going on :-)
    https://www.nuget.org/packages/Xamarin.Firebase.Common/

  • RainerMagerRainerMager JPMember ✭✭

    Good to hear support for Firebase is coming.

  • User.0440User.0440 DEMember

    +1, nice to hear. Are the existing Nuget packages already ready to use (alpha alpha alpha - just for development purposes)?

  • AmySAmyS USMember

    @JamesMontemagno Nice to hear that it's coming! Seems the ones that appeared in Nuget are all for Xamarin.Android? Any plans for iOS?

  • User.0440User.0440 DEMember

    @JamseMontemagno will authentication be supported? Would be great if the default "FriendlyChat" example could be transformed to Xamarin as an example project.

  • RainerMagerRainerMager JPMember ✭✭

    Any guess on when this will be released? Or, is anyone using this in a released app yet? Is it stable enough?

  • PanagiotisKotsibosPanagiotisKotsibos USMember
    edited June 2016

    I have used Xamarin.Firebase in VS-Xamarin-Android to connect to firebase storage database from my android app.
    It raises exception saying that "User does not have permission to access this object"...I can't figure out what to do with Firebase.Auth namespace.
    Can anyone help me;
    Sample below:

    FirebaseOptions o = new FirebaseOptions.Builder()
    .SetApiKey(Application.Context.GetString(Resource.String.firebasestoragekey))
    .SetApplicationId(Application.Context.GetString(Resource.String.firebaseappid))
    .Build();
    FirebaseApp fa = FirebaseApp.InitializeApp(Application.Context, o);
    FirebaseStorage fs = Firebase.Storage.FirebaseStorage.Instance;
    StorageReference sr = fs.GetReferenceFromUrl(storagefile);
    File localFile = File.CreateTempFile(filename, "jpg", Android.OS.Environment.ExternalStorageDirectory);
    sr.GetFile(localFile).AddOnSuccessListener(listener).AddOnFailureListener(listenerf);

  • RainerMagerRainerMager JPMember ✭✭

    Does anyone know the ETA for the Firebase component to be done? It's currently still alpha and hasn't been updated in almost 1 month. https://www.nuget.org/packages/Xamarin.Firebase.Common/

    Thanks.

  • MattJackMattJack FRMember ✭✭

    Hi! i'm also waiting for firebase support! Please keep us informed Xamarin!

  • FarookhMuqriFarookhMuqri GBMember

    Any news whether the first alpha is hit or not?

  • RainerMagerRainerMager JPMember ✭✭

    Also, that Nuget package seems to be Android only, is iOS support planned? When?

  • dot_lydot_ly USMember ✭✭

    bump!

  • I am waiting for the same as well. I am interested in using geofire as well. I see firebase has geofire support for ios and android. I am looking forward for the xamarin equivalent.

  • djlldjll NLMember ✭✭

    Any news? the Alpha nuget package is 1,5 months old atm..

  • Luis_dmLuis_dm USMember ✭✭✭

    Any news?

  • MelbourneTechMelbourneTech AUMember

    Bump

  • sudhir.9350sudhir.9350 INUniversity ✭✭
    edited August 2016

    They have updated to beta (32.4.0-beta2)
    https://www.nuget.org/packages/Xamarin.Firebase.Common/

  • MarkCerezoMarkCerezo USMember ✭✭

    Hey Guys, any news?

  • MikePetersMikePeters USMember ✭✭

    @sudhir.9350 said:
    They have updated to beta (32.4.0-beta2)
    https://www.nuget.org/packages/Xamarin.Firebase.Common/

    I believe this is only for Android. Do you happen to know if there is also one for IOS? I haven't been able to find one.
    Thanks

  • RainerMagerRainerMager JPMember ✭✭

    It seems that beta3 was quietly released on Sep 15. I have no idea what's new in it.

    I keep seeing this error on the console:
    Task exception on worker thread: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist. : com.google.android.gms.measurement.internal.zzt.zzbpu(Unknown Source)

    Has anyone else seen that and have a fix?

  • MarkCerezoMarkCerezo USMember ✭✭

    Has anyone figure out how to implement FCM on Xamarin.Android using stable one?

  • NEkmanNEkman SEMember

    @MarkCerezo

    I managed to get it to work by reading the official FCM documentation and reviewing a sample implementation, from the Xamarin FCM repo. Adding FCM is much more concise than GCM and surprisingly easy, looking forward to a stable release!

    https://github.com/xamarin/GooglePlayServicesComponents/tree/v9.4.0/firebase-messaging

  • tom-smallstom-smalls GBMember ✭✭

    The Xamarin iOS GCM integration guide was replaced with a Firebase one the other week: https://components.xamarin.com/gettingstarted/firebaseioscloudmessaging

  • MarkCerezoMarkCerezo USMember ✭✭

    Hi @NEkman,

    Finally! I got it working. I used 32.4.0-beta2 version to suit on my current Mono version (Because beta3 doesn't work. :neutral: )

    If anyone wants to check my code. I'm happy to help. :sweat_smile:

    Do you guys have any idea on how to create a "Message Sender" (except from Firebase Console Notification) maybe same as what they did here.

    I will be needing this to include on my .net MVC API to send a Notification via Web.

    Thanks in Advance!

  • NEkmanNEkman SEMember

    @MarkCerezo

    You can send messages from you server using HTTP or XMPP. Look at the FCM server docs for details on how to implement it.

  • @MarkCerezo said:
    Hi @NEkman,

    Finally! I got it working. I used 32.4.0-beta2 version to suit on my current Mono version (Because beta3 doesn't work. :neutral: )

    If anyone wants to check my code. I'm happy to help. :sweat_smile:

    Do you guys have any idea on how to create a "Message Sender" (except from Firebase Console Notification) maybe same as what they did here.

    I will be needing this to include on my .net MVC API to send a Notification via Web.

    Thanks in Advance!

    Can you give the source code to view?

  • MarkCerezoMarkCerezo USMember ✭✭

    @NEkman

    Cool! Really help me a lot. I am now able to create my own class on .NET using Send Requests.
    Thanks Man!

    JohnDoe.0007

    I will be uploading the latest code on Github later, maybe you can fork to it then. For now, you can give this a try and let us know the result. I personally, look into this sample methods and changed a bit.

    Also, please note to use 32.4.0-beta2 if you are having trouble with beta3.

  • undefined-userundefined-user USMember
    edited October 2016

    are you using it for Andoid device or only for iOS?

    @MarkCerezo said:

  • MarkCerezoMarkCerezo USMember ✭✭
    edited October 2016

    @undefined-user

    I am using Android device. For iOS, I think they have another component available for that, and was released days ago.

  • undefined-userundefined-user USMember
    edited October 2016

    I'm trying to use sample from v9.4.0 and v9.6.1 and both of them a working correctly. How about "Message Sender" (except from Firebase Console Notification)?

  • undefined-userundefined-user USMember
    edited October 2016

    I'm trying to use sample from v9.6.1 and int the MyFirebaseMessagingService.cs I want to change method > OnMessageReceived as is here: // Check if message contains a data payload.
    if (remoteMessage.getData().size() > 0) {
    Log.d(TAG, "Message data payload: " + remoteMessage.getData());
    }

    but I have not getData, only method Data, and it doesn't contain method size? How can I do this?

  • ArashBijanArashBijan USMember
    edited November 2016

    Noob alert!
    When I try to install Xamarin.Firebase.Common, I get a

    _Could not install package 'Xamarin.Android.Support.Compat 24.2.1-alpha1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.0,Profile=Profile136', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

    _

    What is this?

  • MikePetersMikePeters USMember ✭✭

    Do you guys have any idea on how to create a "Message Sender" (except from Firebase Console Notification) maybe same as what they did here.

    I will be needing this to include on my .net MVC API to send a Notification via Web.

    Thanks in Advance!

    I have had success sending notifications from the web like this:

            public async Task<bool> SendFirebaseNotification(string target, string from, string message)
            {
                try
                {
                    var data = new
                    {
                        to = target,
                        from = from,
                        priority = "normal",
                        notification = new
                        {
                            body = message,
                            title = "Alert",
                            icon = "new"
                        }
                    };
    
                    using (var json = new StringContent(JsonConvert.SerializeObject(data), UnicodeEncoding.UTF8, "application/json"))
                    using (HttpClient client = new HttpClient() { BaseAddress = new Uri("https://fcm.googleapis.com/") })
                    {
                        client.DefaultRequestHeaders.Accept.Clear();
                        client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", String.Format("key={0}", _settings.FirebaseServerKey));
                        client.DefaultRequestHeaders.TryAddWithoutValidation("Sender", String.Format("id={0}", _settings.FirebaseSenderId));
    
                        using (HttpResponseMessage response = await client.PostAsync("fcm/send", json))
                        {
                            response.EnsureSuccessStatusCode();
                            using (HttpContent content = response.Content)
                            {
                                string result = await content.ReadAsStringAsync();
                                JsonConvert.DeserializeObject<object>(result);
                                return true;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    return false;
                }
            }
        }
    
Sign In or Register to comment.