@Sarvesh Gupta Thanks for asking question, Yes the .NET SDK was just published. Please refer to below onboarding steps-
How to onboard to FCM v1 through Azure notification hubs
Steps to use FCM v1 to send push notifications to mobile apps via Azure notification hubs
Android SDK
Step 1. Update SDK Version
Update the SDK version to “2.0.0-preview” in ‘build.gradle’
file of your application
// This is not a complete build.gradle file, it only highlights the portions you'll need to update.
dependencies {
// Ensure the following line is updated in your app/library's "dependencies" section.
implementation 'com.microsoft.azure:notification-hubs-android-sdk:2.0.0-preview'
// optionally, use the fcm optimized SKU instead:
// implementation 'com.microsoft.azure:notification-hubs-android-sdk-fcm:2.0.0-preview'
}
Step 2. (Only if using Templates) Update Payload Template Note: If you are not using templates, skip this step. FCM V1 payload structure: REST Resource: projects.messages | Firebase Cloud Messaging REST API (google.com) Migrating from FCM Legacy payload to FCM V1 payload: https://firebase.google.com/docs/cloud-messaging/migrate-v1#update-the-payload-of-send-requests Example (if using Registrations):
NotificationHub hub = new NotificationHub(BuildConfig.hubName, BuildConfig.hubListenConnectionString, context);
String template = "{\"message\":{\"android\":{\"data\":{\"message\":\"{'Notification Hub test notification: ' + $(myTextProp)}\"}}}}";
hub.registerTemplate(token, "template-name", template);
Example (if using Installations):
InstallationTemplate testTemplate = new InstallationTemplate();
testTemplate.setBody("{\"message\":{\"android\":{\"data\":{\"message\":\"{'Notification Hub test notification: ' + $(myTextProp)}\"}}}}");
NotificationHub.setTemplate("testTemplate", testTemplate);
Server SDKs (Data Plane) Step 1. Add FcmV1Credential to Hub Note: This is a one-time setup. Unless you have a lot of hubs, and want to automate this step, you can simply use the REST API, or the Portal to add the FCM V1 Credential.
// Creating new Notification Hub with FCM V1 Credentials
var hub = new NotificationHubDescription("hubname");
hub.FcmV1Credential = new FcmV1Credential(“private-key", “project-id”, “client-email”);
hub = await namespaceManager.CreateNotificationHubAsync(hub);
// Updating existing Notification Hub with FCM V1 Credentials
var hub = await namespaceManager.GetNotificationHubAsync("hubname", CancellationToken.None);
hub.FcmV1Credential = new FcmV1Credential(“private-key", “project-id”, “client-email”);
hub = await namespaceManager.UpdateNotificationHubAsync(hub, CancellationToken.None);
Step 2. Manage Registrations/Installations
For Registrations:
Use FcmV1RegistrationDescription
to register FCM V1 devices
// Create new Registration
var deviceToken = "device-token"; var tags = new HashSet<string> { "tag1", "tag2" }; FcmV1RegistrationDescription registration = await hub. CreateFcmV1NativeRegistrationAsync(deviceToken, tags);
For Installations:
Use `NotificationPlatform.FcmV1 ``` as the platform with
Installation
, or use ``` FcmV1Installation`
to create FCM V1 Installations
// Create new Installation
var installation = new Installation
{
InstallationId = "installation-id",
PushChannel = "device-token",
Platform = NotificationPlatform.FcmV1
};
await hubClient.CreateOrUpdateInstallationAsync(installation);
// Alternatively, you can use the FcmV1Installation class directly
var installation = new FcmV1Installation("installation-id", "device-token");
await hubClient.CreateOrUpdateInstallationAsync(installation);
Notes:
- If the client app registers itself, then you need to update the Client app first to register under FCM V1 platform.
- If the client app doesn't register itself, you can fetch all registrations/installations and migrate them all to FCM V1 on the server. Step 3. Send Notification to FCM V1 Use ``` FcmV1Notification` `` while sending notifications to target FCM V1
// Send FCM V1 Notification
var jsonBody = "{\"message\":{\"android\":{\"data\":{\"message\":\"Notification Hub test notification\"}}}}"; var n = new FcmV1Notification(jsonBody); NotificationOutcome outcome = await hub.SendNotificationAsync(n, “tag”);
Hope this helps- Please let us know if further query or issue remains.