particle-iot / spark-setup-ios

(DEPRECATED) Spark device setup library - Soft AP Cocoapod/Carthage lib for iOS
Apache License 2.0
19 stars 25 forks source link

Include result in didNotSucceeedWithDeviceID: #50

Open nmccann opened 7 years ago

nmccann commented 7 years ago

For my use case, I'm only interested in configuring the WiFi credentials for my device (without changing it's ownership). Unfortunately in this case didFinishWithResult:device: always passes a nil device. This is understandable, however I need the device ID to pass to my backend, so I have to use didNotSucceeedWithDeviceID:. This method can be called in response to multiple states, so it would be nice if the status was passed as a parameter.

Alternatively I could assume that the method will never be called for a status other than "Succeed Not Claimed", or I could store the status that was passed to didFinishWithResult:device: with the assumption that didNotSucceeedWithDeviceID: will always be called second. Both of these seem like brittle solutions.

I can create a PR with this functionality. To avoid a breaking change I can introduce a new optional delegate method: didNotSucceedWithDeviceID:result: (note that this doesn't include the typo from the current method) or alternatively (and this is my preference): didFinishWithResult:deviceID:. The former option implies that "Success Not Claimed" is a failure, but that might actually be the desired result. The latter option is less opinionated about the result, but could be confusing alongside the similarly named didFinishWithResult:device:

nmccann commented 7 years ago

Alternatively a single method could be used: didFinishWithResult:andID:device: or something similar.

For my use case it's a little odd that didFinishWithResult:device: is a required method, since I never expect to use it. But I admit my use case may not be common.