How to get Google Glass location change notification inside my Glassware - google-mirror-api

Could you please guide me how doing this. I have to get used location changes and have to send some information depend on that location.

See https://developers.google.com/glass/location and https://developers.google.com/glass/v1/reference/locations for complete information about using Locations with Google Glass.
Keep in mind that you need to request the additional scope https://www.googleapis.com/auth/glass.location in order to get any location information.
Once you have done this, Glass will attach the most recently known location (usually where you have been sometime in the past 10 minutes) to any timeline items reported to you.
At any time you can get a list of location updates available, or the "latest" location available from Glass. Additionally, you can subscribe to the "locations" collection (see https://developers.google.com/glass/v1/reference/subscriptions) and you will receive a location change notice roughly every 10 minutes which includes an ID to fetch the associated location.

We can insert subscription for location changes when a user subscribes our Glassware application. After that mirror API will notifies location changes to given url.
Like this
//create a Subscription for location changes
Subscription subscriptionLocation = new Subscription()
{
Collection = "locations",
UserToken = userId,
CallbackUrl = Url.Action("Notify", "Notify", null, Request.Url.Scheme)
};
//insert a Subscription
mirrorService.Subscriptions.Insert(subscriptionLocation).Fetch();

Related

New to Azure Event Grid - trying to react to *any* object being created, deleted or modified

I'm completely new to Event Grid, but have been tasked with creating a way to track anytime any object is created, deleted, or modified within a subscription (additional noise filtering to be added later). Does this sound like I'm on the right track?
Logic App -> Workflow Designer:
When a resource event occurs:
Resource Type - Microsoft.Resources.Subscriptions
Resource Name - (subscription being watched)
Event Type Item - 1
Microsoft.Resources.ResourceDeleteSuccess
Event Type Item - 2
Microsoft.Resources.ResourceWriteSuccess
What I'm completely unclear on is how to output the object deleted/created/modified. Like write to a log or send an email "X" object was deleted by Y user. If anyone has a clue on that, I would greatly appreciate it. Or if there is an easier way to accomplish this, rather than using Event Grid, I'm open to suggestions.
WAY-1
Here is my Logic App flow
I'm using Outlook 365 Connector with Send an Email Action
The Event Data gives whole information on What, When and Who created/modified/Deleted the resource.
Here is the screenshot of the mail that I received.
you can add as many events as possible by clicking Add New Item
WAY-2
You can add logs to your storage account and check the details from there as below.
WAY-3
You can check it in the logs from Overview pane which gives complete details on particular Run Triggers.

Low resolution Email Preview in Salesforce for marketing cloud connect emails

Question about Marketing Cloud Connect - In case of Individual Email Result in Salesforce, an email preview is sent from MC to SF object along with a thumbnail preview of the email template (as base64 encoded image). This thumbnail has two problems.
a. isn’t clear enough for the sales agent to see what was sent to customer
b. can’t find what offer percentage was given to customer as the preview has ampscript value instead of actual value.
There is no way to change the default configs of MCC to increase the thumbnail size. To solve this and improve the image resolution, I’ve thought of below solutions. Is there any other possible way that you’ve done?
From customer send log, take ‘view_email_url’ and get the html using a visual force page and remove all the ‘https://click…xx.com/’ links to ensure click/ open counts aren’t impacted. Downside - # of api calls to make are higher
For every email, create a jpg preview of the email template and store it in MC and store this in SF in a custom object as ‘EmailName vs EmailPreviewUrl’. And, whenever a marketer creates a new email, they have to ensure that they create a jpg copy in MC and update associated record in Saleforce custom object. Downside - sales agent will not know what % of offer is given to customer (ps - % of offer is decided in MC automation based on raw order information we’ve about this customer). To manage this downside, we can send the offer details of each customer to SF using updateSingleSalesforceObject method everytime an email is sent. To do this, all the campaigns should be standardized to some extend.
Any other thoughts? is there any configs that I can flip to increase the image size?
To answer this question, we ended up creating a cloudpage code resource (similar to API) that returns the complete HTML of 'view_email_url' (aka view as web page) for a given email + Subscriber + datesent + BU. We used SSJS to query sendLog DE using these inputs to figure out the view_email_url value. To avoid counting view_email_url opens to tracking opens, we wrapped the open counter pixel inside a context variable - something like below.
%%[
IF _messagecontext != 'VAWP' THEN
]%%
<custom name="opencounter" type="tracking" />
%%[ ENDIF ]%%

When is new Gmail API History ID generated

I am trying to design an algorithm to maintain a list of new INBOX messages using a combination the watch()/push notification, with the user.history and user.messages gmail apis. HistoryID documentation is unclear.
https://developers.google.com/gmail/api/guides/sync#partial
indicates
"You can also use push notifications to trigger partial synchronization in real-time and only when necessary, thereby avoiding needless polling." -- My question is HOW?
Which event on the email account triggers an incremented HistoryID?
If I guess HistoryID I get in the push notification the latest historyId of the label specified, then I should be able to use that HistoryID as the starting HistoryId in the User.History.List call, but when I do I just get an json response which is another higher HistoryID. So, if I'm specifying messagesadded and watching INBOX, why is the call to History API with the most current HistoryID returning no HistoryList objects?
I have read Gmail API users.watch - no details for historyId and Gmail History list is not giving complete data
and I'm unclear as to how to design the algorithm to use push notifications in conjunction with the other apis to do a partial sync to maintain a running inventory on new INBOX messages, as per the documentation.
this issue really sad, google just send historyId with empty history list. But why cant add emailId or property that this history binds with new message arrived?
To solve this problem u need remember time when u last time fetch email messages with total counter messages in Inbox, next, when u get google pub/sub message and it has empty history object - u need get new total counter of messages in Inbox label - if there is differences - next what u need is fetch email messages using:
or
max count value = differences between of total counter messages,
means add query to get messages by max result
or
using date time from your last update - means add query to get messages by date time.
Really bad that google make such bad implementation for pub sub for new messages.

Is there any way to limit a Gmail watch to only messages added?

When setting up a watch for a user is there a way to limit the watch to only messages added to the inbox?
Based on the documentation (https://developers.google.com/gmail/api/v1/reference/users/watch) I see that there is the option for INBOX labelId, but I want to limit it to only messages added as well. We're currently having to handle this by passing 'history/messagesAdded' in the fields string in the subsequent history.list call.
Unfortunately you cannot. what you have to do is
Get the history when notification arrived. History returns a json and it contains a 'messagesAdded' if new message is added.
You can keep a predefined array of labels like below
predefinedLabels = ['UNREAD', 'CATEGORY_PERSONAL', 'INBOX']
Now you can check, (each is the history json)
if 'messagesAdded' in each:
labels = each["messagesAdded"][0]["message"]["labelIds"]
intersectionOfTwoArrays = list(set(predefinedLabels) & set(labels))
Here you get the intersection of labels. Now you have to check that with predefined labels
if set(predefinedLabels) == set(intersectionOfTwoArrays):
#get the messageId and do what you want
finally you can filter the notification as you want!.
It is better to store histroyId and update it with every
notification and use it when you get the history. It will help you
to get updated history only.
Please note I used python when I was building my sever. So above demo code written using python
It looks like history.list added a new parameter "historyTypes". If you set that to "messageAdded", the api will only return history records of that type.

How do I determine which contact a timeline item was shared to?

I am writing an app using the mirror api and I need to be able to share an image that gets associated on the server side with a specific user. I inserted two contacts via my glassware and I can share images to each contact. On the server end I get something back like this but there is no reference to the contact id that it was shared to?
{
u'itemId': u'e2de58b4-e281-4518-8312-948159167be8', # id to image?
u'userToken': u'6b037418-9a7d-4137-943e-2b857f960a80', # user who shared?
u'operation': u'INSERT',
u'collection': u'timeline',
u'userActions': [{u'type': u'SHARE'}]
}
When you request the timeline item with the specified itemId with a timeline.get request, the item will have a recipients property that includes information about which contact it has been shared with, and an attachments property with information about the shared photo itself.
See the according documentation here: https://developers.google.com/glass/subscriptions#shared_picture

Resources