Impossible to register android device in Azure Notification Hub

MCApp 21 Reputation points
2024-08-25T07:08:18.92+00:00

0

I am trying to update my platform (mobile app in xamarin forms and backend in .net7) to set notifications on android devices via the google Fcmv1 system. Unfortunately I can't register the device on my Azure Notification Hub. I tried the various codes that I found on the official documentation but without success. My app sends token to backend and backend tries registration on hub. I don't get any error but anyway I don't find device on hub.

I tried

var nhClient = NotificationHubClient.CreateClientFromConnectionString(ConnectionString, HubName);
var installation = new Installation
{

                InstallationId = $"{device.ID}",

                Platform = NotificationPlatform.FcmV1,

                PushChannel = device.Token,

                PushChannelExpired = false,

                UserId = $"{device.ID}"

            };

await nhClient.CreateOrUpdateInstallationAsync(installation);

and also

var nhClient = NotificationHubClient.CreateClientFromConnectionString(ConnectionString, HubName);
var tags = new HashSet<string> { "tag1", "tag2" };
FcmV1RegistrationDescription registration = await nhClient.CreateFcmV1NativeRegistrationAsync(deviceToken, tags);

and also

var nhClient = NotificationHubClient.CreateClientFromConnectionString(ConnectionString, HubName);
var installation = new FcmV1Installation($"{device.ID}", device.Token);
await nhClient.CreateOrUpdateInstallationAsync(installation);

The hub works correctly for both iOS and android with the old GCM system that now no longer working but the device registration occurs correctly using this code

var installation = new Installation
            {
                InstallationId = $"{device.ID}",
                Platform = NotificationPlatform.Fcm,
                PushChannel = device.Token, 
                PushChannelExpired = false,
                UserId = $"{device.ID}"
            };

I'm really frustrated about this problem. Any idea? Thanks

I tried code found here: https://learn.microsoft.com/en-us/answers/questions/1533052/where-i-can-download-new-version-of-microsoft-azur and other code found on web (pretty much the same of official doc)

I expect to find registered device on hub

Azure Notification Hubs
Azure Notification Hubs
An Azure service that is used to send push notifications to all major platforms from the cloud or on-premises environments.
315 questions
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,338 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.