私のプロジェクトでIonic2とAngular2を使っています。私がcordova-plugin-geofence(https://github.com/cowbell/cordova-plugin-geofence)をインストールすると次のようにジオフェンスが設定されています。Cordova-plugin-geofence onTransitionReceived()メソッドが動作しません。
App.ts
platform.ready().then(() => {
if (window.geofence === undefined) {
console.log('Geofence Plugin not found');
}else{
console.log('Geofence plugin found');
window.geofence.initialize();
const geofence = this.geofenceService.create({
longitude: -8.404015,
latitude: 43.339147,
});
this.geofenceService.addOrUpdate(geofence).then(function() {
console.log('Geofence successfully added');
}, function (reason) {
console.log('Adding geofence failed', reason);
});
}
});
HomePage.ts
window.geofence.onTransitionReceived = function (geofences) {
geofences.forEach(function (geo) {
console.log('Geofence transition detected', geo);
});
}
それはtsubikのように構成されたサービスgeofence.service.tsイオン2ジオフェンスの例:https://github.com/tsubik/ionic2-geofence/blob/master/app/services/geofence-service.ts
すべてのジオフェンス設定プロセスでコンソールにエラーは表示されませんが、window.geofence.onTransitionReceived()メソッドはジオフェンストランジションが発生したときに何も記録しません。
どういうところが間違っていますか?ありがとう!
半径とトランジションタイプを定義する必要があります。半径を閉じるのではなく、1000または3000mのようなものを取ってください。 – Joerg
@Samuel Fraga Mateos、あなたは通知を受けていますか?私はこのプラグインで問題に直面しています。 – AishApp
@Joergデフォルトのジオフェンスで半径とトランジションタイプを定義しました。新しいジオフェンスを作成するときは、緯度と経度のパラメータだけをオーバーライドします。 –