我在 Glassware 应用中订阅了时间线通知。当用户与 Glassware 比赛分享图像时,我收到了通知。现在我需要将该图像下载到我的 Glassware 应用程序中进行处理。
Notification notification =
new NewtonsoftJsonSerializer().Deserialize<Notification>(Request.InputStream);
String userId = notification.UserToken;
MirrorService service = new MirrorService(new BaseClientService.Initializer()
{
Authenticator = Utils.GetAuthenticatorFromState(Utils.GetStoredCredentials(userId))
});
if (notification.Collection == "timeline")
{
foreach (UserAction action in notification.UserActions)
{
if (action.Type == "SHARE")
{
TimelineItem item = service.Timeline.Get(notification.ItemId).Fetch();
//i have to download content here.
break;
}
else
{
Console.WriteLine(
"I don't know what to do with this notification: " + action.ToString());
}
}
}