Mobile Software Development Kit beta announcement
Today, we’re excited to launch a beta version of the much anticipated Mobile Software Development Kits (SDKs). With this release, you are no longer on your own when building an app for your Spark-powered product or prototype — we are providing tools to make it easy to interact with the Spark cloud from your mobile device. iOS support is here, Android support is coming soon!
The Elite and Champions have already had a chance to tinker around with these SDKs, and now we’re looking for your feedback!
Multi-layered SDK
There are two parts to this SDK beta release: the Cloud SDK and the Device Setup library.
Cloud SDK
The Cloud SDK is a library that enables your mobile app to interact with internet-connected hardware through the Spark Cloud. It serves the same purpose as Spark JS — it’s an easy-to-use wrapper for our REST API, accessible from beautiful, idiomatic Objective-C and Swift. Using the Cloud SDK, you can:
- Manage user sessions for the Spark Cloud (access tokens, encrypted session management)
- Claim/Unclaim devices for a user account
- Get a list of instances of claimed Spark devices
- Read variables from devices
- Invoke functions on devices
- Coming Soon: Publish events from the mobile app and subscribe to events coming from devices
All cloud operations take place asynchronously and use the well-known completion blocks (closures for swift) design pattern for allowing you to build beautiful responsive apps for your Spark products.
Device Setup library
The Device Setup library allows you to create a setup wizard for connecting your device with two lines of code.
As you may have heard, the wireless setup process for the Photon uses very different underlying technology from the Core. Where the Core used Smart Config, the Photon uses what we call “soft AP” — the Photon advertises a Wi-Fi network, you join that network from your mobile app to exchange credentials, and then the Photon connects using the Wi-Fi credentials you supplied.
With the Device Setup library, you make one simple call from your app, for example when the user hits a “setup my device” button, and a whole series of screens then guides the user through the soft AP setup process. When the process finishes, the user is back on the screen where she hit the “setup my device” button, and your code has been passed an instance of the device she just setup and claimed.
It’s pretty magical.
But what if you have your own branding in the rest of your app and don’t want the setup wizard to suddenly change to look Sparky? Well, for that, we’ve made the setup UI super easy to customize! There’s a customization proxy class that includes properties such as: custom colors, texts, fonts, brand logos and a placeholder for an instructional video file for setting up your product. There are good defaults if you don’t set these properties, but you can override the look and feel as needed to suit the rest of your app.
How To Get Started?
iOS
Both the Cloud SDK and Device Setup library are available through CocoaPods, the most widely used iOS dependency manager. If you don’t have it, you’ll need to start by installing the cocoapods
ruby gem; check out the CocoaPods site for more info.
Then, to install the Device Setup library for iOS (which has the Cloud SDK as a dependency), simply add the following line to the Podfile
in your iOS project root folder:
pod "SparkSetup"
You can find the documentation here (currently on cocoadocs.org website, we’ll have full documentation and usage coverage soon):
Documentation for iOS Cloud SDK
Documentation for iOS Device Setup library
In addition you can simply consult the javadoc style comments for each SDK public method for detailed usage explanation.
The mobile SDKs use the same LGPL license as most of our open source repositories, so submitting issues and contributions through pull requests is most welcome!
You can find the source code in our GitHub:
Repository of iOS Device Setup library
There’s also an example app in Swift that demonstrates the basic usage of invoking the setup wizard, customizing its UI and using the returned SparkDevice
class instance once Device Setup wizard completes.
Android
We’re still working on Android, but it’s not far behind. The overall process is very similar, but it’s a native Java experience so Android developers will feel right at home.
One big difference in the user experience of setting up a Photon from an Android app vs. an iOS app is that on Android an app can control which Wi-Fi network the phone connects to, whereas on iOS the user has to leave the app, go to settings, and change the Wi-Fi network. We’ve made both flows as easy as possible, but it’s definitely smoother on Android since the user doesn’t have to do as much.
The Cloud SDK and Device Setup library for Android will soon be available on our GitHub and through JCenter as Apache Maven packages.
Go Forth and Build Apps!
We’d love to hear what you think of the mobile SDKs so far. We’re so excited to get your valuable feedback in this thread! That being said, a couple of things to keep in mind:
- We will announce the Android SDK the moment it becomes available (did we say soon?)
- This is not a finished product, and there will likely be bugs found. We wanted to focus on shipping you all something quickly to begin iterating based on feedback and usage. We don’t expect this to be production-ready, and neither should you! There are numerous additional features and elements coming—this is just a start
- We so appreciate your feedback, thoughts and ideas. Please keep them coming! We’re building this for all of you, and we will incorporate your feedback into future versions of the mobile SDKs.
Our goal at Spark is to make it as easy as possible to build IoT products, from prototype all the way into production, and beyond. This is just one more way we’re putting the power in your hands to create an amazing experience for your users.
We’re seriously stoked to see how you are going to put the mobile SDKs to use!
Thanks for being awesome!