A React Native integration for the Particle iOS SDK.
Using this basic app as an example, you should be able to integrate the setup process of Particle-powered products into your own React Native app.
If you aren't familiar with the process of creating native modules, React Native have some useful documentation to get you started.
You will need node.js, Watchman, the command line interface for React Native, and Xcode installed. Follow the Getting Started guide (Building projects with Native Code) to ensure these are all correctly installed.
$ git clone https://github.com/pixielabs/particle-react-native-bridge-example.git
$ cd particle-react-native-bridge-example
$ yarn
You'll then need to build and run the app from within Xcode using the generated project workspace.
In this example, we use the Particle Device Setup Library only; this allows you to create a setup wizard inside your app for users to manually configure their Particle devices.
In addition to creating the native modules ParticleSetupBridge.m
and ParticleSetupViewController.m
(together with their header files) as per the sample app, you'll need to install the Particle library via Cocoapods. Follow the installation instructions in the Particle documentation.
For your mobile app to interact directly with internet-connected hardware, you'll need to integrate separately with the Cloud SDK.
For example, if you use your own backend to authenticate your users, you can use the Cloud SDK to inject their session access token and treat them as logged in. Simply add the following code to ParticleSetupBridge.m
before setting up the ParticleSetupMainController
:
if ([[ParticleCloud sharedInstance] injectSessionAccessToken:accessToken]) {
NSLog(@"Session is active!");
} else {
// Do something here to alert the user that their token has expired.
// They'll need to log in again.
return;
}
Currently, this example app deals with iOS only - but we'd love for it to support Android too. We'd be very happy for any contributors to help flesh this out - simply fork this project, start a feature branch and make a pull request!