Optimize IoT connectivity with subscriptions and notifications

ARTIK Cloud’s promise to developers is that you can work freely with data regardless of the source or silo. We currently have Cloud Connectors that bridge third-party clouds with ARTIK Cloud, and we also have subscriptions and notifications functionality. This allows devices or clouds to subscribe to ARTIK Cloud and receive notifications whenever new messages or Actions are available.

The idea behind ARTIK Cloud  subscriptions and notifications is to allow for two specific use cases:

  • Third-party services can define a connection to ARTIK Cloud that is tailored to their purpose.
  • Devices on ARTIK Cloud can optimize their bandwidth usage.

For those of you with high-bandwidth devices and applications that require real-time data streaming, WebSockets are still your best solution. But if your application framework doesn’t allow for WebSockets, or you aren’t expecting to move data at a high frequency, then subscriptions and notifications are for you.

How it works

SAMI subscription and notification

The new documentation gives a detailed, step-by-step walkthrough of how SAMI subscriptions and notifications are created. Here we want to give you a general view of what the process entails.

First, your client (application or device) makes an API call to create the subscription. You choose whether the client should be listening for “message” or “action” messages. The former contain only data, and the latter contain Actions, or commands sent to a device.

You can customize the relevant devices in the subscription. When listening for message type “message”, you can specify:

  • Every user-owned device.
  • Every user-owned device of a specific device type.
  • A single user-owned device.

When listening for message type “action”, you can specify:

  • A single user-owned device (that receives Actions).

Note that all devices in a subscription must have granted permissions to the client.

ARTIK Cloud then initiates a brief process by which your client confirms the subscription, after which the subscription becomes active.

When it receives a relevant message, ARTIK Cloud sends an notification (not the message) to your client’s callback URL. The notification is authenticated according to the OAuth 1.0 specification and has to be verified by your client. Then your client can parse the notification payload for the notification ID, which it uses in an API call to retrieve the messages attached to that notification.

Remember, subscriptions and notifications are not meant to move data at high frequencies. Actions are sent immediately; otherwise, notifications are queued every 30 seconds and sent in batches.

The feature in action

As part of ARTIK Cloud’s integration with our partner SmartThings, we have implemented ARTIK Cloud subscriptions and notifications with SmartApps, which are scripts that enable SmartThings device automation.

The SmartApp can subscribe to receive messages (message type “message”) from ARTIK Cloud devices, or Actions (message type “action”) targeted to SmartThings devices. SmartThings devices can thus receive commands from the ARTIK Cloud ecosystem, and a SmartThings app can get status updates from ARTIK Cloud devices.

Dive in

Subscriptions and notifications give you even more granular control over your applications and devices, and—most importantly—how you want to deal with the data that matters to you. Read our documentation article for all the necessary details on the above steps, and see the APIs listed here.