Waking up connection during activity.

Hi,

So I have an app that uses a purchase service for licensing. 

I allow users to run once as a trial, then I poll license status using makeWebRequest. 

Also, I have logic to wait for connection - if no connection at the time it’s called, it tries again a few seconds later, until there is one. (Only when checking licence.)

I am checking connection availability based on code I saw here from Jim, and in the simulator it works across the board. 

But...

On the device, it sometimes fails to find a connection even if I explicitly synch the watch or toggle Bluetooth... I have to exit and reenter to see the valid connection that is there. 

Is there a way to jumpstart the connection?

For example, I’m assuming I need to wait till connection available / has connection before making the request, but would makeWebRequest inspire the device to look for a connection?

Thanks,

G

  • If you are doing this in the background, remember you can run every 5 minutes at most.

    Typically, I don't check connection status before doing a makeWebRequest, and just check the responseCode in the call back.  Doing a makeWebRequest doesn't try to force a connection.

    In the sim, things work much faster than on a device, so when connecting with BT, etc, it's pretty much instantaneous, while on a device, can take longer to establish BT, etc.  Also, what happens if you are out of BT range, the phone is off, etc?

  • If you are doing this in the background, remember you can run every 5 minutes at most.

    Yes, the licence process for WF is a bit clunky as a result... that and the fact that I have the aesthetic sensibility of a slug mean I steer well clear of WF! This is an app not a WF so no background needed.

    Typically, I don't check connection status before doing a makeWebRequest,

    I'm going to try this on a "build for device" and see if it makes things any better.

    what happens if you are out of BT range, the phone is off, etc?

    That's why I'm checking connection status in any case!

    The logic is something like:

    If connection, make request immediately

    Otherwise, set timer and make request if a connection is available at the end of the timer

    I'm going to change that instead to:

    Make request immediately, 

    If response is good, use it. Otherwise, set a timer and try again later.

  • It might be undocumented, but I think Garmin might not bother checking unless it has a reason to. By making that one change (calling without waiting for a connection) I have more than quadrupled the number of people who get their trial start formally logged. (I also shortened trial workout which meant more get to see a purchase code, but that's secondary.)

    Anyway, all good. Slight smile