Agent URL returned as 'undefined'

Hey!

We are doing a custom blinkup app and sometimes the Native plugin returns an Agent URL with the Agent Id being undefined. For example, I would get agent.electricimp.com/undefined returned from both the iOS and Android sdks. Is anyone having this problem?

Thanks!

The only point at which the iOS BlinkUp SDK (19.3.1) will return an agent URL is in the the code black registered by the devicePollingDidComplete: parameter of the blinkUpController presentInterfaceAnimated: method. This returns a BUDeviceInfo object, of which agentURL is a property. That’s if the device enrollment process went smoothly. Of it didn’t, devicePollingDidComplete: will return a non-null NSError value, so you should always check for a non-null error before you check for an agentURL.

See https://electricimp.com/docs/manufacturing/sdkdocs/ios/19/basic/#bubasiccontroller

The Android SDK (6.0.0) provides a callback function structure which you pass to BlinkUpController via the latter’s getTokenStatus() method. If there’s an error or timeout, the agent URL won’t be defined. This can trip you up if you’re storing the agent URL as a global and reading its value without first checking the result of the TokenStatusCallback.

See https://electricimp.com/docs/manufacturing/sdkdocs/android/6/callbacks/#tokenstatuscallback.

The process might fail (ie. enrollment is rejected, so no agent URL is returned) if you’re using an invalid Plan ID, eg. a development Plan ID for a production device. See the Android SDK link above for more info on this.