2

I have created a timeline card with a custom menu item. I would like to get a callback when the user has selected that menu item.

// 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();

I then subscribe to all timeline events and provide an https callback 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.");
}
So the subscription is created without any issues as far as I can tell. But after interacting with the card, I never get a callback. What am I missing?

Things I have tried:

  1. Populating Ids on the subscription obj, timeline card, and menuItem
  2. Subscribing before creating the card instead of after
  3. Adding the userId as the UserToken on the subscription object
  4. Calling my callback URL directly to ensure that it is listening

JSON Response from GET /mirror/v1/subscriptions:

{
 "kind": "mirror#subscriptionsList",
 "items": [
  {
   "kind": "mirror#subscription",
   "id": "timeline",
   "updated": "2013-10-28T15:19:19.404Z",
   "collection": "timeline",
   "callbackUrl": "https://mypubliclyavailableserver.com/notify"
  }
 ]
}
Software.Developer
  • 991
  • 10
  • 16

3 Answers3

0

I am not an expert on this subject. But searching for the same topic, I found this https://developers.google.com/glass/subscription-proxy, according to this, don't you need to have the forward url? I think the callback url format is not right in your example?

theman
  • 1
  • My understanding is that proxy is useful for development purposes if you do not have a publicly available site with a valid SSL cert. it allows you to redirect to an HTTP endpoint. Also, I've tried using the proxy to no avail. – Software.Developer Oct 29 '13 at 15:02
  • Do you mind posting your timeline resource response? I wonder if the timeline notification has to have the deliverytime set? – theman Oct 29 '13 at 16:35
  • The JSON response for the timeline card can be seen here http://hastebin.com/wajapajule.xml – Software.Developer Oct 29 '13 at 17:23
0

Have you tried without the "operation" all together.

var subscription = new Subscription() { Collection = "timeline", CallbackUrl = "https://mypubliclyavailableserver.com/notify" }

It's an optional https://developers.google.com/glass/v1/reference/subscriptions/insert

theman
  • 1
0

It turns out there was a problem with my SSL certificate at my callback URL https://mypubliclyavailableserver.com/notify

It worked when I tried to hit my webservice from hackst.com. I guess they ignored the "Could not establish trust relationship for SSL/TLS secure channel" error that Google was seeing.

There is no location which Google can send the error, so I just never knew whether it was calling me or not. Perhaps if during the subscription process, if the callback URL's cert does not appear valid, an error could be returned?

Software.Developer
  • 991
  • 10
  • 16