Closed kyle-ssg closed 8 years ago
Sure, there you go:
You can get an active instance of SparkDevice by making your viewcontroller conform to protocol
-(void)SparkSetupViewController:(SparkSetupMainController *)controller didFinishWithResult:(SparkSetupMainControllerResult)result device:(SparkDevice *)device;
This method will be called. If (result == SparkSetupMainControllerResultSuccess) the device parameter will contain an active SparkDevice instance. You can get its device-id by just probing device.id
Good luck
Thanks so much for the quick response! I have a feeling I tried this however started getting keychain issues.. Again Objective C is completely new to me.. Will have to try again when i get my hands on a photon. From what I understand then I just add this to my app delegate ?
@interface AppDelegate() <ReactNativeAutoUpdaterDelegate>
@end
@implementation AppDelegate
-(void)SparkSetupViewController:(SparkSetupMainController *)controller didFinishWithResult:(SparkSetupMainControllerResult)result device:(SparkDevice *)device {
//emit event with device.id
}
.....
Looks good. Investigating the keychain issue. btw, you can always go the Swift way if Obj-C feels weird to you
Hi again. I'm getting SparkSetupResultSuccessUnknown as the result and device is null, however the device connected successfully.
Hi, could you perhaps shed any light on this? I imagine it could either be due to my device in particular, or perhaps the device doesn't return with initWithSetupOnly:YES
This means that the cloud detected the device as offline just after finishing setup and could not generate an instance. Is it happening all the time?
Seems to be happening every time yes, I'll try on my WIFI at home perhaps in that case as it takes quite a bit longer to connect at work.
Let me know how it goes
Hi again, it seems to still happen when tethering to my phone. Eventually I'll be working with a chipset that goes dormant as soon as it successfully connects to the network in order to save battery, I imagine this approach won't work here.
Upon inspection it seems getDeviceID is successfully retrieving a detectedDeviceID during setup. Is there a way I can simply pass that to the setupDidFinishObserver ?
Edit: Looking in checkForInternetConnectivity, it looks like it finishes with SparkSetupResultSuccessUnknown if self.needToClaimDevice is false.. Is this not because I'm using initWithSetupOnly:YES?
Ended up implementing
didFinishWithResult:(SparkSetupMainControllerResult)result deviceID:(NSString *)deviceID
returns deviceID in either success or unknown, this shall suffice for what I need.. Thanks!
Hey Kyle,
Would you mind helping me integrate the set up library with React Native?
Having some issues, I also have little to no knowledge of Objective-C.
Thanks in advance,
KillerGasy
@kyle-ssg Any help possibly?
Which part do you need help with? You basically just need to include the particle iOS sdk in your xcode project with either cocoapods or carthage, and then you build a custom class as seen on the OP to create a wrapper for it. Import it in your javascript, and you can then access it.
You can read about creating and using native components here: https://facebook.github.io/react-native/docs/native-components-ios.html
I have been able to do that part. The main part in which I am having trouble is getting the ID from a successful connection and giving it to the React-Native side of the application. @steve-haskins
Pining this thread as i have the same issue using the same parameters as @kyle-ssg had and we are using swift. So does it mean we need to override the default library behavior as well?
Hey, this is less of an issue more of a question. I'm looking to port this to a react native app. I've got the setup working however I'm wondering if I can get the connected device id as part of any callback? I have next to no objective c experience so I'm probably missing something :). I've written a simple bridge as follows: