Communications.makeWebRequest

Hi guys, 

Can anyone explain how these requests are handled if a watch app is told to make a request and either the phone with GCM is out of range ...... or the phone is in range but there is no service.

Are the requests cued automatically next time the watch is within range of the phone? Or do app requests need to be turned into background running items that continually stay on until the watch and phone are re-united?

Secondly - what level of functionality does the simulator allow. Can I expect the Sim running on a PC to make the communication as GCM would and pass any data back / fourth to the internet?

Thanks

  • there is no queuing.  If a makeWebRequest is made, an error will be seen in the callback if it can't be done.  -104 is what you'll see if there is no connection to the phone.  Here's the full list: https://developer.garmin.com/connect-iq/api-docs/Toybox/Communications.html.

    The sim is close to real world, but you may find small difference with GCM iOS and GCM Android.  Also, some devices (edge devices for example) which will use wifi and GCM isn't involved in a simple makeWebRequest.

  • As far as backgrounding that kind of depends on the app type and what your app is doing.

    I have widgets that always request data every x Minutes, but on devices without backgrounds, ot's done in the foreground when the widget is opened.  On watch faces, it's only in the background.

    But I also cache data when I get itand can sill display it unless it's too old.

  • Thanks Jim.... as always you have good advice! In theory my app will be used away from the phone, and it's very probable that users will exit the app completely before getting into range of the WIFI or Mobile device.

    I could either try when they exit to leave a background service running that tries every X minutes to make the call ( could be hit or miss )....... or I could code into the app whenever the watch app opens, to attempt to pass the data ( small amount ) then ( since the link to the webpage will reside inside GCM app settings - they will be next to the phone when they want to read the data. )

    I'm leaning towards the latter,

    To clarify your comment on the watch simulator - so you are saying the watch simulator will always simulate good connection with GCM or WIFI, and will actually make the calls and receive returns from the internet?

    and another question I had - I created a property that is read only.... I thought this would mean if a user looks at the property in GCM settings, it would be read only.... but I also seem to have no ability myself to change the property using code inside the app.  Is this the correct functionality, and if so is there a way to display a setting to the user, that is read only for them ( they may need to see the information) , but able to be changed by the application internally ?  

  • Under Settings>Connection Type in the sim you can disconnect BLE and simulate you're not connected to the phone.