Kontakt.io’s New Proximity SDK
What is the new SDK?
So you want to add all the best beacon capabilities to your app or platform but don’t know the ins and outs of coding? The Kontakt.io Proximity SDK is the simplest way to manage triggers and proximity-based actions just by integrating a few lines of code.
Proximity SDK is perfect for beginners who want to implement triggers…
- No need to understand majors, minors, and UUIDs
- Save time on coding and prototyping
- Create a minimum viable product or prototype in minutes
What can you achieve using Kontakt.io Proximity SDK?
The main functionalities offered by the SDK are:
- fetching and resolving triggers,
- monitoring iBeacon regions,
- monitoring Eddystone regions,
- automatic data synchronization.
When to use which SDK?
Not sure whether to use our existing, core SDK or choose the new Proximity SDK? It can be difficult to decide, as some issues can be resolved by using the first, while others might benefit from the second.
In general, if you want to:
- manage triggers
- monitor iBeacons or Eddystones with only a few lines of code
- integrate beacon-related solutions with existing applications very easily
Then it’s better to choose Proximity SDK.
The new SDK, however, doesn’t cover all functionalities of the core SDK. If you need to implement custom logic different from monitoring regions (i.e. applying configs, updating firmwares etc.), you should use the existing SDK.
The new SDK provides a very simple interface for monitoring iBeacon and Eddystone regions with only a few lines of code. Want to see how simple it is? Take a look at the review sample codes provided below.
Until now, if you wanted to listen for iBeacon and Eddystone actions you would probably implement something similar to this:
That’s quite a lot of code, especially if there are only a few events that require reactions. Now let’s take a look at another approach of monitoring iBeacons and Eddystones using the new SDK:
Simple, right? As you can see, the amount of code required is significantly less. The significant difference is that we’re handling region and namespace entered/abandoned events rather than single devices. What’s even better about Proximity SDK for Android is that it ensures we get callbacks even if our app is in the background – that simply isn’t possible with the first sample code.
The example code below presents iBeacons monitoring and Eddystones discovery using KTKBeaconManager in combination with KTKEddystoneManager:
The code above could be simplified by using KTKProximityManager, which is a main component of Proximity SDK for iOS:
If you prefer an approach with delegates you can instantiate KTKProximityManager with delegate parameter.
What is a trigger and how can I create one?
By definition, a trigger is an event that causes something to start. It’s an action. Both elements – trigger and action – are tightly coupled with each other. Using our web panel you can create multiple triggers linked with various actions. The relationship between the two is “many to many.” In other words, a single trigger can have many actions and also a single action can be attached to numerous triggers.
Let’s focus first on the trigger. Log into your Kontakt.io Panel account, go to the Triggers section and click the ADD TRIGGER button. This navigates us to the trigger creation form. To start we need to specify the executor type. This should be PROXIMITY SDK. Only triggers of this type will be fetched and monitored by the SDK. Another step is to define an event as a trigger. This could be beacon detection (by unique ID/mac address) or entering/leaving iBeacon and Eddystone regions. In the second instance you should input either iBeacon or Eddystone region data. For iBeacon you have to specify at least Proximity UUID – so available combinations are: [Proximity UUID], [Proximity UUID, Major] and [Proximity UUID, Major, Minor]. Eddystone region data, on the other hand, consists of a single namespace ID or is used in combination with instance ID.
In order to better understand the whole trigger creation process, please see the video below.
Once the triggers are properly created we can create actions for them. Select trigger and go to ASSIGN ACTIONS tab. If the list is empty, you have to first define the action. Click ADD AN ACTION button.
Before creating an action let’s define what the term means within a software context. An action is nothing but execution of a HTTP request. So what’s the big deal?
First of all, you can send every request to your own backend API, meaning it can be used in all kinds of different use cases. You can simply ‘beaconize’ every service currently provided to your clients.
Another approach is to make use of existing solutions. There are a few tools like IFTTT which provides us API to execute various services through sending POST requests with contextual data as body parameters. As a result of making API call, we can, for example, add a row to a Google spreadsheet, post something on Facebook, send a message through multiple communication channels and many, many more actions. It’s up to you to determine how to utilize this powerful functionality.
For presentation purposes let’s create an action that tries to connect with a fake server by sending an HTTP POST with body parameters. All you have to do is to change the URL and add/change optional request headers and parameters to reflect your own values.
If you want to learn more about how to define triggers and actions, please visit this tutorial.
Once we create a complete set of triggers and have actions assigned to them, we can monitor trigger execution events through the new Kontakt.io Proximity SDK.
From the moment we start listening for triggers, the SDK will try to resolve every beacon detection or region enter/exit event in order to match them with created triggers. If any trigger event happens, the proper request will be executed, informing the Kontakt.io Cloud that it should execute all actions assigned to the trigger. Every time a trigger is detected, users will be notified about the result of execution through a proper callback mechanism, dependent on the concrete platform.
Below you can find sample codes showing how to set up Proximity SDK on different platforms in order to monitor triggers.
The main objective of Proximity SDK is to provide as simple an interface as possible. Consequently, such a solution enables quick and easy integration with any customer’s application. Not to mention, all previously highlighted functionalities can be mixed up. We can manage triggers and monitor regions at the same time or use them separately. As a result, the new SDK is completely at your service – allowing you to choose modules and configure settings to get the desired coverage you need.
This SDK one is far more simplified than its predecessor and can be adapted into your projects with ease. It’s the perfect choice if you want to keep track of all proximity-based actions with minimal effort. Please do keep in mind that Kontakt.io Proximity SDK doesn’t cover all functionality from the core module, but we think you will agree there is still much to be excited about with its release.