Grzegorz Cichocki
Grzegorz Cichocki

Reputation: 13

Firebase device token on Xamarin.Forms

I have a Xamarin.Forms project and I'm using the firebase messaging platform to provide push notifications to my app. The last step that is stopping me from publishing the app is the lack of FirebaseInstanceId Nuget for xamarin.forms which seems to exist only for xamarin.android. The reason behind why it is so important for my project is getting the cloud messaging token. From what I've seen throughout internet forums it wasn't covered clearly what to do in this situation.

The notifications in my app work in an unusual way. The user chooses one of around 30 options, and then depending on his choice he receives appropriate push notification. So I've written a script that sends his choice to the firebase database and that is where his token is required so a javascript server connected to firebase could send him the push.

I hope I made it clear, and that that the solution wasn't covered previously on this forum. I'm still a beginner so a detailed solution or some suggestions would be really appreciated.

Upvotes: 1

Views: 3257

Answers (1)

nevermore
nevermore

Reputation: 15786

To implement notifications in Xamarin forms, you should do it on each platform(iOS and Android)and install Nuget packages to each platform.

  1. Create a Xamarin.forms project name MyApp(Use this Name as an Example).

  2. Right Click on the MyApp.Android(This is important, not MyApp) ---> Manage NuGet Packages You should install these packages in Android Project:

    (1). Xamarin.GooglePlayServices.Base

    (2). Xamarin.Firebase.Messaging

  3. Right Click on the MyApp.iOS(This is important, not MyApp) ---> Manage NuGet Packages
    You should install these packages in iOS Project:

    (1). Xamarin.Firebase.iOS.CloudMessaging

You can follow this article for more detail :firebase-cloud-messaging.

Upvotes: 1

Related Questions