Worklight - 在Wifi中连接触发器是一个错误

时间:2014-02-26 09:23:31

标签: android triggers wifi ibm-mobilefirst android-geofence

功能

loadWifiTracking() {

      var policy = {

            Wifi: {
                interval: 3000,
                signalStrengthThreshold: 15,
                accessPointFilters: [{SSID:"wifiName"}]
            }
      };

      var triggers = {

        Wifi: {

            DwellInSide: {
                type: "DwellInside",
                areaAccessPoints: [{SSID: 'wifiName'}],
                callback:function() {alert("Thank You For Being Here!");},
                dwellingTime: 5000
            },

            Connected: {
                type: 'Connect',
                connectedAccessPoint:[{SSID: 'wifiName'}],
                callback: function() {alert("Reached Here");}
            },

        }

      };


     WL.Device.startAcquisition(policy, triggers, acquisitionFailure);

         var acquisitionFailure = {

             Wifi : wifiFailure,

     };

     function wifiFailure(positionError) {

        alert("pe" + positionError);

     }

}

这是一个错误:

The WIFI Connect trigger with network specification: [{"SSID":"wifiName"}] will have no affect, since this network do not appear in WIFI acquisition policy.

任何想法究竟是什么问题?请帮忙。

1 个答案:

答案 0 :(得分:2)

Connected: {
                type: 'Connect',
                connectedAccessPoint:[{SSID: 'wifiName'}],
                callback: function() {alert("Reached Here");}
            },

正如您在Connect触发器中看到的那样,属性connectedAccessPoint是单数。因此,您不应传递SSID数组,而应传递单个SSID。

尝试:

Connected: {
                    type: 'Connect',
                    connectedAccessPoint:{SSID: 'wifiName'},
                    callback: function() {alert("Reached Here");}
                },