Following the code in the reference documentation for the iOS SDK, I am unable to read variables or functions from the Particle Cloud. Running the code below does not list any of the variables or functions on the Photon which are exposed to Particle Cloud.
func loginWithCredentials(userName:String, userPassword:String) {
ParticleCloud.sharedInstance().login(withUser: userName, password: userPassword) { (error:Error?) -> Void in
if let _ = error {
// catch login failure
print("Wrong credentials or no internet connectivity, please try again")
} else {
print("Logged in")
var myPhoton : ParticleDevice?
ParticleCloud.sharedInstance().getDevices {(devices:[ParticleDevice]?, error:Error?) -> Void in
if let _ = error {
print("Check your internet connectivity")
} else {
if let d = devices {
for device in d {
if device.name == "photon" {
myPhoton = device
}
}
}
//print the contents of myPhoton
print(myPhoton!)
}
}
}
}
}
Here is the printed output:
Logged in
<ParticleDevice 0x282f10410, type: Photon, id: 2c001f000a47363339343638, name: photon, connected: true, flashing: false, variables: {
}, functions: (
), version: 1.4.0, requires update: false, last app: (null), last heard: 2019-10-15 09:06:15 +0000, notes: (null), networkId: (null), networkRole: 0, networkRoleState: 0>
What am I doing wrong?