I am using Communications.makeWebRequest to relay measurement data to my webserver. I have found that this works well when my watch is connected to an android phone. However, with iOS devices it seems that I get a -104 / BLE_CONNECTION_UNAVAILABLE error unless Garmin Connect is open on the iOS device (or has been opened recently).
I still get notifications on my watch from incoming text messages etc. so it seems as though the Bluetooth connection is still active at some level. Once I open GCM on the iPhone, the -104 error goes away.
Has anyone else run into this? I am guessing iOS is doing something to prevent GCM from relaying the request in the background when GCM has been unused for too long. Any tips on preventing this behavior either in the way that I call makeWebRequest or by changing settings on the iOS device?
Here is the code that I use to make the request.
function postHTTP(data as Lang.Dictionary) as Void { var delegate = new WebRequestDelegate(data); var url = "https://example.com"; data["key"] = $.userKey; data["name"] = $.userName; var options = { :method => Communications.HTTP_REQUEST_METHOD_POST, :headers => {"Content-Type" => Communications.REQUEST_CONTENT_TYPE_JSON}, :responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON }; delegate.makeWebRequest(url, data, options, self.method(:onReceive)); }