particle-iot/ios-app-example-pod

Name: ios-app-example-pod

Owner: Particle

Description: Barebones example Swift iOS app demonstrating how to use the ParticleSetup / SDK cocoapod libraries

Created: 2015-04-13 22:36:53.0

Updated: 2018-04-24 02:11:11.0

Pushed: 2018-03-10 01:06:46.0

Homepage:

Size: 13554

Language: Swift

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

iOS-app-particle-setup

Barebones Swift iOS app showcasing basic ParticleSetup / Particle-SDK cocoapods usage / getting started.

Versioning: macOS 10.13.3, XCode 9.2 (Swift 4), Cocoapods 1.4, Particle-SDK pod 0.7, ParticleSetup pod 0.8

How was it created?
  1. Open XCode. File->New->Project->Single View App->Your project name
  2. Create Podfile with your target name and Particle pods reference (see file)
  3. Close XCode Project
  4. Open shell window and navigate to the project folder
  5. Run pod install (make sure your have latest Cocoapods installed), pods will be installed and new XCode workspace file will be created.
  6. in XCode open the new <your project name>.xcworkspace
  7. Add bridging header - see file Particle-Bridging-Header.h for reference.
  8. Go to project settings->build settings->Objective-C bridging header->type in ./<your project name folder>/Particle-Bridging-Header.h (or wherever file is located).
  9. Create the source code and storyboard for your app (see ViewController.swift and Main.storyboard for reference)
  10. Build and run - works on simulator and device (no need to do any modifications to Keychain settings)
  11. Click “Start setup” on the phone and onboard a new Photon to your account.
Code

ViewController invoking Particle setup must adhere to the ParticleSetupMainControllerDelegate protocol and implement (at least) the funcion func particleSetupViewController(_ controller: ParticleSetupMainController!, didFinishWith result: ParticleSetupMainControllerResult, device: ParticleDevice!).

To invoke setup:

et setupController = ParticleSetupMainController()

setupController.delegate = self //as! UIViewController & ParticleSetupMainControllerDelegate
self.present(setupController, animated: true, completion: nil)

To reference the Particle cloud use: ParticleCloud.sharedInstance(), to reference a device use: var device : ParticleDevice or use a returned device instance from a cloud function like:

evice != nil

device.getVariable("test", completion: { (value, err) -> Void in
    print(value)
})

For questions - refer to Particle mobile knowledgebase/community here: https://community.particle.io/c/mobile

Good luck!


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.