how to spoecific platform type registrations from Azure Notification Hub?

Mahalakshmi 0 Reputation points
2024-05-29T03:59:33.01+00:00

Hi,

I am using Azure Notification Hub to send push notifications. My application is developed in the .NET framework. Currently, I am using GetAllRegistrationsAsync to retrieve all the registrations. However, this method does not provide access to the platform type of each registration. I need to get only FCM/GCM registrations and Apple registrations from the Notification 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.
290 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Marcel Gille 10 Reputation points
    2024-07-01T10:58:18.77+00:00

    You can get the type of the RegistrationDescription and filter through that.
    To following example should give you an idea on how to do it.

    var response = await hub.GetAllRegistrationsAsync(0);
    
    response.ToList().ForEach(regDesc =>
    {
        if(regDesc.GetType() == typeof(FcmRegistrationDescription))
    	{
    		//do transform stuff for change to FcmV1RegistrationDescription and reregister
    	}
    });
    
    1 person found this answer helpful.
    0 comments No comments