我有一个使用数据json api .l的离子应用程序,用于航班时刻表的详细信息。当用户单击铃铛时,如果要到达,延迟或降落,他会收到有关航班状态的通知。我为离子安装了Local Notifications native 。
home.ts
保留数据json网址
constructor(private http: HTTP, private localNotifications: LocalNotifications) {
this.getdata()
}
async getdata() {
const loading = await this.loadingController.create({
message: 'Loading'
});
await loading.present();
this.http.get('/airport.json?code=bs', {}, {})
.then(data => {
this.test = JSON.parse(data.data);
const parsed = JSON.parse(data.data);
this.yestrday = parsed.result.response.airport.pluginData.schedule.arrivals.data;
loading.dismiss()
}), err=>{
this.test =err
loading.dismiss()
}
}
navigate(item,aiprot,time,type,status,airline,logo){
this.nav.navigateForward(`/flightserachdetails/${item}/${aiprot}/${time}/${type}/${status}/${airline}/${logo}`);
}
}
关于航班详细信息的页面保存数据
export class FlightserachdetailsPage {
public flight : any
callsign =null
airport = null
status = null
aircraft = null
airline = null
time = null
logo = null
constructor(private http: HTTP, public loadingController: LoadingController,private localNotifications: LocalNotifications,
private nav : NavController,private activatedRoute : ActivatedRoute) {
this.activatedRoute.params.subscribe((params) => {
this.callsign = params['callsign'];
this.airport = params['airport'];
this.time = params['time'];
this.aircraft = params['aircraft'];
this.status = params['status'];
this.airline = params['airline'];
this.logo = params['logo'];
});
}
AlertFlight(){
if (this.status=='Landed') {
this.localNotifications.schedule({
title: 'My first notification',
text: 'flight is landed',
foreground: true
});
}
}
}
html
<button item-right clear (click)="AlertFlight()">
答案 0 :(得分:0)
您要在AlertFlight()方法中检查的条件是-- manually switch to database2
ALTER SESSION SET CURRENT_SCHEMA = schema2
SELECT * FROM table2;
,但图像中显示的状态是“ 已放行”。因此,请更改条件
this.status=='landed'
答案 1 :(得分:0)
这里是普通js中的一个示例,它在angular中的工作方式相同。
<!DOCTYPE html>
<html>
<head>
<script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-beta.7/dist/global/Rx.umd.js"></script>
<script>
let subject = new Rx.Subject();
let status = "";
Rx.Observable.of("").subscribe(x => {
setTimeout(() => {
status = "departed";
subject.next("status");
}, 1000),
setTimeout(() => {
status = "enroute";
subject.next(status);
}, 10000),
setTimeout(() => {
status = "landed";
subject.next(status);
}, 10000);
});
subject.subscribe(x => {
AlertFlight();
});
function AlertFlight() {
if (status == "landed") {
console.log("landed alert");
}
}
</script>
<title>Page Title</title>
</head>
<body></body>
</html>