Android 如何设置azure通知中心注册的过期日期

Android 如何设置azure通知中心注册的过期日期,android,azure,notifications,azure-mobile-services,azure-notificationhub,Android,Azure,Notifications,Azure Mobile Services,Azure Notificationhub,您好,我想为azure通知中心注册设置过期日期。我使用下一行进行通知中心注册 NotificationHub hub = new NotificationHub(mGCMPreferences.getHubName(), mGCMPreferences.getConnectionString(), mContext); String registerId = hub.register(token, mGCMPreferences.getTagId()).getRegistrationId()

您好,我想为azure通知中心注册设置过期日期。我使用下一行进行通知中心注册

 NotificationHub hub = new NotificationHub(mGCMPreferences.getHubName(), mGCMPreferences.getConnectionString(), mContext);
 String registerId = hub.register(token, mGCMPreferences.getTagId()).getRegistrationId();

您能建议我在注册时设置有效期吗?

根据您的代码,您似乎正在使用Azure NotificationHubs SDK for Android来实现您的需求,因此请在查看其javadocs

根据Android版Azure NotificationHubs SDK的&for class
Registration
,没有任何公共方法可以设置
ExpirationTime
,从
NotificationHub
对象更新
Registration
对象。因此,无法在android端设置过期数据

但是,您可以尝试使用Azure NotificationHubs SDK for Java后端来完成此操作,请参阅位于的后端javadocs

作为参考,这里是一个示例代码

String connectionString = "<your connection string>";
String hubPath = "<your hub path>";
NotificationHub hub = new NotificationHub(connectionString, hubPath);
// Get the registration by Id
String registrationId = "<your registration id>";
Registration registration = hub.getRegistration(registrationId);
// Set the expiration date
Date expirationTime = new Date(....);
registration.setExpirationTime(expirationTime);
字符串连接字符串=”;
字符串hubPath=“”;
NotificationHub hub=新的NotificationHub(connectionString,hubPath);
//通过Id获取注册信息
字符串注册ID=“”;
注册=hub.getRegistration(注册ID);
//设置过期日期
日期到期时间=新日期(..);
注册。设置expirationTime(expirationTime);

如果您必须在Android端设置过期数据,我的建议是您可以尝试使用Notification Hubs REST API和属性
registrationTtl
来完成此操作。

有帮助吗?@NikitaG。对不起,这个答案对我没有帮助。