强制关闭应用程序(杀死)时,本地通知不起作用

时间:2018-12-11 11:04:46

标签: json ionic-framework

我有一个php服务器,向我发送了一组JSON,当JSON有任何变化时,我需要显示一些本地通知,因此我在ionviewdidload()中设置了一个计时器,并执行了类似的通知方法这个

localnotification(){
    let notify_cuttent  = []; 
    this.httpClient.get(this.current).subscribe( tipList => {
        for (let i = 0; i < tipList['current_tips'].length; i++) {
            const element = tipList['current_tips'][i];
            notify_cuttent.push(element);
            if (notify_cuttent.length > this.CurrentList.length ||
                notify_cuttent[i].call !== this.CurrentList[i].call ||
                notify_cuttent[i].entry_price !== this.CurrentList[i].entry_price ||
                notify_cuttent[i].special_note !== this.CurrentList[i].special_note ||
                notify_cuttent[i].stop_loss !== this.CurrentList[i].stop_loss ||
                notify_cuttent[i].take_profit_1 !== this.CurrentList[i].take_profit_1 ||
                notify_cuttent[i].take_profit_2 !== this.CurrentList[i].take_profit_2   
                ) {
                console.log("higher length", );
                let notify_title = notify_cuttent[i].instrument;
                this.localNotifications.getAll().then(dataAll => {
                    console.log("notification it",dataAll.length, dataAll);
                    console.log(dataAll.length )
                    if (dataAll.length > 1) {

                        if (dataAll[i].text ==  'Check' +' '+ this.CurrentList[i].instrument +' '+ 'for new updates open app' 
                        ) {
                            console.log(i,"same text found nothing to be done")
                        } else {
                            console.log(i,"no text found",dataAll.length, notify_title);
                            //need to push a notification if there is no notification exist
                        }
                    } else {
                        console.log("no notification exist");
                        this.localNotifications.schedule({
                            id: dataAll.length + 1,
                            title: 'Current data',
                            text: 'Check' +' '+ notify_title +' '+ 'for new updates open app',
                            smallIcon: 'res://imgs/fox',
                            icon: 'file://assets/imgs/fox.jpg',
                            foreground: true
                        });
                    }


                })

            }
        }

    })  
}

所以notify_cuttent具有来自php服务的JSON,而this.CurrentList是移动设备中的本地数据,因此我将比较这两个数据并提出通知

我面临的问题 如果通知再次关闭,它将返回,直到我打开应用程序并查看 如果应用程序已被强制关闭,但我没有收到通知

有人可以帮我吗

0 个答案:

没有答案
相关问题