Search code examples
azure-notificationhub

I'm installing a Microsoft.Azure.NotificationHubs Installation Class withExpirationTime property in null


I have a doubt about ExpirationTime property which belongs to Installation class, this Installation class is on Microsoft.Azure.NotificationHubs project. Here is link for the documentation about it https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.notificationhubs.installation?view=azure-dotnet

My question is, what will happen to the installation that goes without value in ExpirationTime property on Azure? Do they expire? Or I don’t have to worry about it anymore, and if they expire, is there a way to get the property value? Is there any example?

I'm using this code to register the installation of the devices on azure, and I'm worry about if they're going to expire some day and I will need to register again all the devices.

var hubConnectionString = "myazureconnectionstring";
string hub = "myhubname"; 
NotificationHubClient HubClient=NotificationHubClient.CreateClientFromConnectionString(hubConnectionString, hub, true);

Installation installation= new Installation
{
     PushChannel = device.DeviceToken,
     Platform = device.Type==DeviceType.iOS? NotificationPlatform.Apns: NotificationPlatform.Gcm,
     InstallationId = device.registrationId ?? await HubClient.CreateRegistrationIdAsync()
};     
await HubClient.CreateOrUpdateInstallationAsync(installation);

regards.


Solution

  • The default expiration time is infinity. So you don’t have to worry about it expiring.

    Here is the sample code to get the expiration time. This is at the hub level

    var namespaceManager =NamespaceManager.CreateFromConnectionString(“******”);

    NotificationHubDescription desc = namespaceManager.GetNotificationHub("apnstest_amol");

    Var expiration = desc.RegistrationTtl;

    Thanks, Amol