Can we receive step data in the pub sub payload? - jawbone

I can see in the payload JSON that the pubsub notification includes the events but is it also capable of sending the activity or sleep amounts (e.g steps or sleep minutes)?

No, the pubsub notification will only include the user and the list of events that took place. You can then use this information to query the APIs that pertain to those specific types of events.
For example, suppose you receive the following pubsub notification:
{
"notification_timestamp": "1372787949",
"events": [
{
"user_xid": "RGaCBFg9CsB83FsEcMY44A",
"event_xid": "EJpCkyAtwoO0XTdkYyuTNw",
"type": "move",
"action": "creation" ,
"timestamp": "1372787849"
},
{
"user_xid": "RGaCBFg9CsB83FsEcMY44A",
"event_xid": "blaHyAtwoO0XTdkYyuTNw",
"type": "sleep",
"action": "updation" ,
"timestamp": "1372787859"
}
],
"secret_hash": "e570b3071a0964f9e2e69d13nd9ba19535392aaa",
}
Then you know that a move event was created and that a sleep event was updated for the user specified by user_xid: RGaCBFg9CsB83FsEcMY44A
Use this user's xid to determine which previously saved access_token to send with your next API requests.
You can get the details for the move event by sending a request to the moves endpoint with the event_xid: EJpCkyAtwoO0XTdkYyuTNw:
GET https://jawbone.com/nudge/api/v.1.1/moves/EJpCkyAtwoO0XTdkYyuTNw
And yo ucan get the details for the sleep event by querying the sleeps endpoint with the event_xid: blaHyAtwoO0XTdkYyuTN:
GET https://jawbone.com/nudge/api/v.1.1/sleeps/blaHyAtwoO0XTdkYyuTN

Related

Enrich device life cycle events Azure IoT Hub

I need to enrich the device life cycle events[Created, Deleted, Connected, Disconnected] received on Event Grid.
The event flow in my solution is like below:-
Device send registration request to IoT Hub -> Event grid triggers device life cycle event -> Event grid routes device life cycle event to Event Hub.
Since my application i.e. consumer to Event hub only that is the reason I'm routing all events to Event Hub from Event Grid.
Now, I need to enrich the event received on Event hub. For example, the device connected event should look like below:
{
"body": [
{
"id": "58b1872d-1388-8043-dacc-6322ca65d2bf",
"topic": "SOME_TOPIC",
"subject": "devices/diablo-central-park-1",
"eventType": "Microsoft.Devices.DeviceConnected",
"data": {
"deviceConnectionStateEventInfo": {
"sequenceNumber": "SOME_SEQ_NUMBER"
},
"hubName": "IOT_HUBNAME",
"deviceId": "DEVICE_ID"
},
"dataVersion": "",
"metadataVersion": "1",
"eventTime": "2020-10-16T06:33:42.2418032Z"
}
],
"properties": {
"aeg-output-event-id": "SOME_ID",
"aeg-subscription-name": "SOME_NAME,
"aeg-delivery-count": "0",
"aeg-data-version": "",
"aeg-metadata-version": "1",
"aeg-event-type": "Notification",
"enrichedProperty": "enrichedValue"
},
"offset": "25769816448",
"sequenceNumber": 2197,
"enqueuedTimeUtc": "2020-10-16T06:33:49.321Z",
""systemProperties": {}
}
So, In above event JSON, I should get the enrichedProperty in the properties field. I have done message enrichment for twin change events, telemetry through Message routing(Enrich Messages)in IoT hub blade on the portal. But for device life cycle events I could not find a way.
This should work in a very similar manner. So you create an end point (e.g. a storage container), then create a route making sure you choose "Device Lifecycle Events" in the data source of the route. then go to "enrich messages" tab and add the name and value of the property that you want , making sure the correct end point is selected. Also make sure that the root is enabled and the route query is true. Now when you create or delete a device, your events will be captured and the enriched property will appear in the captured event properties.

FCM API returns a success response but push notification is not delivered to user

I am sending push notification using FCM legacy API and by request looks like the following
POST https://fcm.googleapis.com/fcm/send
{
"to" : "USER-DEVICE-TOKEN",
"collapse_key" : "type_a",
"priority" : "high",
"notification" : {
"body" : "Getting this?",
"title": "Let me know if you got this message",
"icon": "ic_launcher"
},
"data": {
"one": "two"
}
}
This request returns the following response
{
"multicast_id": 144107415xxxxxxxxx,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
{
"message_id": "0:1581xxxxx5%32xxxxxxxxx"
}
]
}
But the user never receives any push notification. This happens for most of the user but about 10% of total user does receive push notification send by the same mechanism. I am out of sorts regarding this, I don't know whats going on or even how to go about debugging this. Has anyone run into this issue? The app is written in React Native and uses invertase/react-native-firebase for firebase features. Thanks

Firebase Cloud Messaging Reports - not displaying sent count in Reports

We have set "analytics_label" in the message as stated in the documentation and the message is getting delivered as well. But we do not see any entry in the report. Please check our message string and let us know what might be wrong. Appreciate your help.
REST API being called
https://fcm.googleapis.com/fcm/send
Message being sent
{"topic":"81xxxxx42","android":{"priority":"high"},"priority":"high","fcm_options":{"analytics_label":"nwy81xxxxx42"},"data":{"MID":-1,"frm":"99xxxxx32","MTP":9,"msg":""}}
I'm not certain what library you're using or if you're just POSTing directly to the REST API, but looking at code that I know works I think you just need to make fcm_options and analytics_label camel case.
{
"topic": "81xxxxx42",
"android": {
"priority": "high"
},
"priority": "high",
"fcmOptions": {
"analyticsLabel": "nwy81xxxxx42"
},
"data": {
"MID": -1,
"frm": "99xxxxx32",
"MTP": 9,
"msg": ""
}
}

How to know the Shopify username who triggered a webhook?

I have a product/update Shopify webhook. When the webhook event comes, I see the JSON payload but I don't get any clue about who updated the product. I need the username or email or whatever to identify the user who triggered the webhook. Is that even possible ? If yes, how ?
As per Shopify Documentation, product/update hook does not contain any information regarding the user who triggered the action. However, if it is extremely important for you to find out the user, a workaround is to use the Shopify Events API. As you already have the Product ID in the recieved webhook, you may issue another call to
GET /admin/products/#{product_id}/events.json
and in the response
{
"events": [
{
"id": 677313116,
"subject_id": 921728736,
"created_at": "2008-01-10T08:00:00-05:00",
"subject_type": "Product",
"verb": "create",
"arguments": [
"IPod Touch 8GB"
],
"body": null,
"message": "Product was created: IPod Touch 8GB.",
"author": "Shopify",
"description": "Product was created: IPod Touch 8GB.",
"path": "/admin/products/921728736"
}
]
}
you will have the author field. You may further filter the result using verb and created_at fields.
The supported events are
But I am also only able to get the created, published and unpublished events.

Graph API Subscription Notification Fires Continuously

I am creating subscriptions to a OneDrive folder using the Graph API and I am receiving change notifications continuously (every half a second) even when the contents of the folder (or even the drive itself) is not changing. (Obviously I was expecting that I would receive notifications only when the folder contents change).
I post the following JSON to create the subscription:-
{
"clientState": "GraphAPITest1 2018/05/01 11:31:26",
"notificationUrl": "https://123e7ff5.ngrok.io/notification/listen",
"resource": "/drives/b!X5kF-EHEkECCcjyJ3Fh1CTQI-5nOBktJv57zZdpp13CPQb_8FIV-RIPt-7fnzyxP/root",
"expirationDateTime": "2018-05-02T11:31:26.0881202+01:00",
"changeType": "updated"
}
The notification that my service receives is:-
{
"value": [
{
"subscriptionId": "2467af01-a616-4493-8947-220146c4828a",
"clientState": "GraphAPITest1 2018/05/01 11:23:13",
"resource": "/drives/b!X5kF-EHEkECCcjyJ3Fh1CTQI-5nOBktJv57zZdpp13CPQb_8FIV-RIPt-7fnzyxP/root",
"resourceData": null,
"changeType": "updated",
"subscriptionExpirationDateTime": "2018-05-02T10:23:13.3640899+00:00"
}
]
}
I get the same behaviour in my own code as well as in Microsoft's example app (https://github.com/OneDrive/onedrive-webhooks-aspnet). My code uses an app-only authentication token but the Microsoft example forces user authentication - both suffer from the same behaviour.
Any idea what I need to do to only get notifications when the contents of the folder actually changes?
Barry