我创建了带有自定义菜单项的时间轴卡。当用户选择该菜单项时,我想获得一个回调。
// Create a menu item for the card
var mnuActivate = new MenuItem() {
Action = "CUSTOM",
RemoveWhenSelected = new bool?(true),
Id = ACCEPT_ID,
Values = new List<MenuValue>() {
new MenuValue() {
State="DEFAULT",
DisplayName="Activate",
},
new MenuValue() {
State="PENDING",
DisplayName="Activating..."
},
new MenuValue() {
State="CONFIRMED",
DisplayName="Activated"
}
}
}
// Create a new card for the user's timeline
var item = new TimelineItem() {
Html = html,
Notification = new NotificationConfig() { Level = "DEFAULT" },
MenuItems = new List<MenuItem>() { mnuActivate }
};
var card = this._service.Timeline.Insert(item).Fetch();
然后,我订阅所有时间轴事件并提供一个https回调URL
// Create a new subscription
var subscription = new Subscription()
{
Collection = "timeline",
Operation = new List(),
CallbackUrl = "https://mypubliclyavailableserver.com/notify"
};
this._service.Subscriptions.Insert(subscription).Fetch();
// Retrieve a list of subscriptions to make sure it is there.
var mySubcriptions = this._service.Subscriptions.List().Fetch();
if (mySubcriptions != null && mySubcriptions.Items != null && mySubcriptions.Items.Count == 1)
{
Console.WriteLine("Subscription created successfully.");
}
据我所知,创建订阅时没有任何问题。但是在与卡片互动之后,我再也没有收到回叫。我想念什么?
我尝试过的事情:
在订阅obj,时间轴卡和menuItem上填充ID
在创建卡之前(而不是之后)订阅
在订阅对象上添加userId作为UserToken
直接调用我的回调URL以确保它正在侦听
GET / mirror / v1 / subscriptions的JSON响应:
{
"kind": "mirror#subscriptionsList",
"items": [
{
"kind": "mirror#subscription",
"id": "timeline",
"updated": "2013-10-28T15:19:19.404Z",
"collection": "timeline",
"callbackUrl": "https://mypubliclyavailableserver.com/notify"
}
]
}
最佳答案
我不是这个问题的专家。
但是搜索相同的主题时,我发现了这个https://developers.google.com/glass/subscription-proxy,
据此,您不需要转发网址吗?我认为您的示例中的回调网址格式不正确?
关于c# - 如何从Glass收到有关已选择自定义菜单项的通知?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19600123/