Hi,experts, I am making a watchface that need activation. A weird problem arised, the https request was not executed on some devices like fenix5xPlus and Tactix,but most devices like fr series worked fine. My code is like below. Sorry I cannot insert a code snippet,perhaps cuz of the risk control for a vpn access?
I have made these efforts:
- check this thread,but I cannot confirm without explcit log. https://forums.garmin.com/developer/connect-iq/i/bug-reports/makewebrequest-bad-request-on-some-devices
- change my interface to https
- write a lot of logs in my server program. ie. if the web request is made, there would be at least a line of log.
- Let my user checked the GCM network connection and BLE connection between the mobile and his watch. He has no idea about side-loading and the most awkard thing is he doesnt own a pc , so I cannot collect any logs from side-loading debug on real devices with issues.
So can you give me any suggestions to find the culprit? THX, have a nice weekend
(:background)
class App extends Application.AppBase {
function initialize() {
AppBase.initialize();
}
function onSettingsChanged() as Void {
InitBackgroundEvents();
setActivationTask();
WatchUi.requestUpdate();
}
function setActivationTask(){
Storage.setValue("needCheckActivation", true);
}
function InitBackgroundEvents(){
var FIVE_MINUTES = new Toybox.Time.Duration(5 * 60);
var lastTime = Background.getLastTemporalEventTime();
var nextTime;
if (lastTime != null) {
nextTime = lastTime.add(FIVE_MINUTES);
Background.registerForTemporalEvent(nextTime);
} else {
nextTime = Time.now();
Background.registerForTemporalEvent(nextTime);
}
}
function getServiceDelegate(){
return [new BackgroundServiceDelegate()];
}
function onBackgroundData(data) {
if (data != null){
doSomething();
}
}
}
import Toybox.Application;
import Toybox.Application.Storage;
import Toybox.Application.Properties;
import Toybox.Time;
import Toybox.Time.Gregorian;
import Toybox.Background;
import Toybox.System;
import Toybox.Communications;
// The Service Delegate is the main entry point for background processes
// our onTemporalEvent() method will get run each time our periodic event
// is triggered by the system.
(:background)
class BackgroundServiceDelegate extends System.ServiceDelegate {
function initialize() {
System.ServiceDelegate.initialize();
}
function onTemporalEvent() {
var needCheckActivation = Storage.getValue("needCheckActivation");
var activated = Storage.getValue("activated");
if(needCheckActivation){
System.println("activate will be performed");
activate();
}
}
function activate(){
var activationCode = Properties.getValue("ActivationCode");
var settings = System.getDeviceSettings();
if(settings != null && (activationCode == null || activationCode.equals("") || activationCode.length() == 32)){
System.println("http activation will be performed");
var options = {
:method => Communications.HTTP_REQUEST_METHOD_POST,
:headers => {"Content-Type" => Communications.REQUEST_CONTENT_TYPE_JSON},
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
};
var code = sign(settings.uniqueIdentifier,activationCode,"appname");
Communications.makeWebRequest(
"">ip.com/.../activate",{
"code" => code
},
options,
method(:responseCallbackActivation)
);
}
}
function responseCallbackActivation(responseCode, data) {
if (responseCode == 200){
}else{
}
Background.exit(null);
}
function isValidActivationResult(result){
}
}