如何在Azure Notification Hub注册中更新到期时间? [英] How to update Expiration Time in Azure Notification Hub registration?

查看:85
本文介绍了如何在Azure Notification Hub注册中更新到期时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Azure通知中心已有一段时间了.但是,我为一个新项目创建了一个新的Notification Hub,我注意到了一些非常奇怪的行为.每当我创建注册时,其ExpirationDate都会设置为12/31/9999 7:59:59.

I've been working with Azure Notification Hubs for awhile. However, I created a new Notification Hub for a new project and I've noticed some very odd behavior. Whenever I create a registration its ExpirationDate is set to 12/31/9999 7:59:59.

因此,对于某些人来说,我认为这可能是一种好处,但是我想在一段时间不活动后将其过期.我浏览了RegistrationDescription对象,发现一个ExpirationTime,但是它是只读的...

So, for some, I suppose this may be a benefit, but I'd like to expire mine after a certain period of inactivity. I looked through the RegistrationDescription object and found an ExpirationTime but it's read only...

该如何设置?这仅仅是Azure中的错误吗?也许是Azure配置中缺少的标志?

How do I set this? Is this just a bug in Azure? Maybe a flag I'm missing from Azure configuration?

推荐答案

您可以执行此操作,但是可以在中心级别上进行,而不能在注册级别上进行.查看改进的每条消息遥测和设备有效期通知中心博客文章:

You can do that, but on hub level, not on registration level. Check out Improved Per Message Telemetry and device expiry for Notification Hubs blog post:

要利用此有效期更改,只需更新您的 通知中心的生存时间"属性.这可以通过完成 REST或我们的.NET SDK:

To take advantage of this expiry change, simply update your notification hub’s Time To Live property. This can be done through REST or our .NET SDK:

var namespaceManager = NamespaceManager.CreateFromConnectionString("connectionstring");
NotificationHubDescription hub = namespaceManager.GetNotificationHub("foo");
hub.RegistrationTtl = TimeSpan.MaxValue;
namespaceManager.UpdateNotificationHub(hub);

要通过REST API进行此操作,请检出更新通知中心方法,该方法使用 NotificationHubDescription 正文,其中有一个RegistrationTtl节点.那应该是与上述SDK代码段相同的REST.

To do that via the REST API, check out Update Notification Hub method, which takes NotificationHubDescription body, which has a RegistrationTtl node in it. That should be a REST equivalent of the SDK code snippet above.

这篇关于如何在Azure Notification Hub注册中更新到期时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆