onTransitionReceived()未在Cordova中用于退出区域

时间:2019-03-06 07:52:39

标签: android cordova cordova-plugins phonegap-plugins geofencing

我正在为cordova应用程序使用geofence插件,如果用户位于当前区域,而用户却无法调用onTransitionReceive区域,那么我将被调用onTransitionReceived回调方法

代码

function onDeviceReady() {
    window.geofence.initialize().then(function() {

    }, function(error) {
        alert("Error", error);
    });

    let fence = [{
        id: "69ca1b88-6fbe-4e80-a4d4-ff4d3748acdb",
        latitude: xx.956786,
        longitude: xx.743058,
        radius: 1000,
        transitionType: 1,
        notification: {
            id: 11,
            title: "Welcome!",
            text: "You're in.",
            openAppOnClick: true
        }
    }, {
        id: "69ca1b88-6fbe-4e80-a4d4-ff4d3748acdc",
        latitude: xx.956786,
        longitude: xx.743058,
        radius: 1000,
        transitionType: 2,
        notification: {
            id: 22,
            title: "bye!",
            text: "You're out .",

        }
    }]

    window.geofence.addOrUpdate(fence).then(function() {
        navigator.notification.alert('successfully added', function() {});
    }, function(reason) {

        navigator.notification.alert('failed', function() {});
    })

    window.geofence.onTransitionReceived = function(geofences) {
        geofences.forEach(function(geo) {
            alert("geo " + JSON.stringify(geo));
        });
    };

};

任何帮助将不胜感激

0 个答案:

没有答案