firebase - Ionic 3 背景位置不起作用。当APP进入后台时,后台位置不会在firebase上更新
问题描述
app.component.ts
构造函数(平台:平台,statusBar:StatusBar,splashScreen:SplashScreen,私有backgroundMode:BackgroundMode,公共cs:CustomService){platform.ready()。then(()=> {
statusBar.styleDefault();
splashScreen.hide();
this.backgroundMode.enable();
this.cs.startBackgroundLocation();
});
}
自定义服务.ts
setInterval(()=>{
this.count = this.count+1;
firebase.database().ref('test/').set(this.count);
},3000)
let options = {
frequency: 3000,
enableHighAccuracy: true
};
this.backgroundGeolocation.watchLocationMode()
this.watch = this.geolocation.watchPosition(options).filter((p: any) => p.code === undefined).subscribe((position: Geoposition) => {
console.log(position);
if(position){
firebase.database().ref('testingData/')
.set({
lat:position.coords.latitude,
lng:position.coords.longitude
}).then(()=>{})
}
this.zone.run(() => {
this.lat = position.coords.latitude;
this.lng = position.coords.longitude;
});
});
解决方案
推荐阅读
- python - Python Turtle setworldcoordinates 负值
- python - 方位角归一化
- python - PyNaCl 更改随机数大小
- c - 如何从可变长度函数创建宏?其中宏值是另一个可变长度函数
- ios - 没有互联网连接时,`DeviceCheck` API 可以生成令牌吗?
- python-3.x - python请求中的多处理
- php - 无法访问 Microsoft Dynamics 365 Business Central 的 APIS
- macos - HAL 虚拟设备:如何“代理”麦克风
- python - 山楂到铁木的迁移(Open edX)
- php - 多个查询 mysqli