@aligassan wrote:
My app is content on flight schedule and every thing working fine . i have put button , that button when user click on he will receive local notifications about flight status he want . l used to cordova plugin local notifications and Background mode . l use Background mode plugin to keep my app perform infinite background execution to check flight status then send local notification to user . l used if expression to check flight status if arrived push notification if not keep looping . Even l used set Interval to keep data reloading to check flight status . All those steps i did i didn’t get any notification even though if status of flight is arrived
full code
export class FlightserachdetailsPage implements OnInit { public flight: any public myFlag = true; callsign = null airport = null status = null aircraft = null airline = null time = null logo = null id: any myStatus: boolean; constructor(private http: HTTP, public loadingController: LoadingController, private nav: NavController, private activatedRoute: ActivatedRoute, private backgroundMode: BackgroundMode , private localNotifications: LocalNotifications, public alertController: AlertController) { 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']; this.id = params['id']; if (this.status == "landed") { this.myFlag = true console.log(this.myFlag) } else { this.myFlag = false } if (this.status == "estimated") { this.myStatus = true console.log(this.myFlag) } else { this.myStatus = false } }); this.backgroundMode.enable() } ngOnInit() { } ///Alert confirm to receive notification async RecNotifi() { const alert = await this.alertController.create({ header: 'Confirm!', message: 'Are you sure you do want receive notification about flight ' + this.callsign, buttons: [ { text: 'Cancel', role: 'cancel', cssClass: 'secondary', handler: (blah) => { console.log('Confirm Cancel: blah'); } }, { text: 'Okay', handler: () => { console.log('Confirm Okay'); this.ActiveNotif() } } ] }); await alert.present(); } //// execute to active code check for flight status async ActiveNotif() { this.http.get('xxxxxxxxxxxxxx.json?flightId=' + this.id + '', {}, {}) .then(data => { let FlightDetails = JSON.parse(data.data).result.response.data.flight let identification = FlightDetails.identification.callsign let status = FlightDetails.status.generic.status.text if (status == "landed") { this.localNotifications.schedule({ title: 'Your flight has arrived', text: 'Your flight '+identification + 'is arrived', foreground: true }); } setInterval(()=> { this.ActiveNotif() }, 4000); console.log('notifiction is running ',data.data) }) } navigate(id, callsign, status) { this.nav.navigateForward(`/map-track-befor/${id}/${callsign}/${status}`); } handleImgError(ev: any, item: any) { let source = ev.srcElement; let imgSrc = `/no__logo.png`; console.log(imgSrc) source.src = imgSrc; } }
any idea please ?
Posts: 1
Participants: 1