Итак, в основном я пытаюсь создать запланированное локальное уведомление из средства выбора DateTime из Ionic
Пользователь выбирает час и минуту, когда он хочет, чтобы уведомление появилось, я делаю так:
мой html-файл
<ion-button style="padding-right: 15px; padding-left: 20px" size=""><ion-datetime displayFormat="HH:mm" [pickerOptions]="customPicker" [(ngModel)]="tempo" (ngModelChange)="Tempo()">Alarm</ion-datetime>
</ion-button>
И файл .ts:
tempo: string;
horas: string;
minutos: string;
customPicker: any;`
constructor () {
this.customPicker = {
buttons: [{
text: 'Salvar',
handler: async () =>{
this.localNotifications.schedule({
title: 'Atenção',
text: '',
data: { mydata: 'Lembre-se de fazer a técnica Hertz' },
trigger:{ every: { hour: Number(this.horas), minute: Number(this.minutos)}, count: 1 },
foreground: true // mostrar notificação com o app em background
})
}
}]
}
}
Tempo(){
this.horas = this.tempo.slice(0,2);
this.minutos = this.tempo.slice(3,5);
}
Когда я выберу нужное время и нажму «Сохранить», приложение закроется. Logcat показывает мне это:
FATAL EXCEPTION: pool-1-thread-1
Process: io.ionic.starter, PID: 19945
java.lang.ClassCastException: org.json.JSONObject$1 cannot be cast to java.lang.Integer
at de.appplant.cordova.plugin.notification.Request.getMatchingComponents(Request.java:219)
at de.appplant.cordova.plugin.notification.Request.buildTrigger(Request.java:158)
at de.appplant.cordova.plugin.notification.Request.<init>(Request.java:75)
at de.appplant.cordova.plugin.localnotification.LocalNotification.schedule(LocalNotification.java:270)
at de.appplant.cordova.plugin.localnotification.LocalNotification.access$400(LocalNotification.java:60)
at de.appplant.cordova.plugin.localnotification.LocalNotification$1.run(LocalNotification.java:145)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)