Xamarin Android SDK

How to integrate Pushwoosh SDK into your Xamarin Android project

Module Source Geozones Module Source Download Sample

Android Platform Configuration

1. Go to https://console.firebase.google.com/ and create a new project

2. Go to Your Project > Project settings:

3. In Cloud Messaging tab find Server Key and Sender ID:

4. Go to Pushwoosh Control Panel > Your Application > Configure and open the Android platform settings:

5. Insert Server Key and Sender ID from your Firebase project to the corresponding fields and save changes:

SDK Integration

1. Add Nuget package "Pushwoosh Xamarin Android SDK" to your project. 2. Add the following metadata to AndroidManifest.xml:

<meta-data android:name="com.pushwoosh.appid" android:value="XXXXX-XXXXX" />
<meta-data android:name="com.pushwoosh.senderid" android:value="@string/fcm_sender_id" />

Where:

  • com.pushwoosh.appid is your Pushwoosh Application Code

  • com.pushwoosh.senderid is the Sender ID you got from the Firebase Console (See Step 5 of Android Platform Configuration guide).

Please note that you need to add fcm_sender_id to res/values/strings.xml of your project (create this file if necessary):

strings.xml
<resources>
<string name="fcm_sender_id">YOUR FCM SENDER ID</string>
</resources>

3.1. Add google-services.json file to your project.

google-services.json

You should've gotten the google-services.json file while creating the app in Firebase console. If you haven't, please consult this thread (section Get a config file for your Android app).

3.2. In Visual Studio, right-click the google-services.json and choose GoogleServicesJson option from the Build Action menu.

4. Register for push notifications:

using Pushwoosh;
PushNotificationsManager.Instance.RegisterForPushNotifications();

That's it!