Reputation: 153
So I want my app to fire notification every 3 hours by users choice when to start this, there is a Toggle on the HTML that if the user turn it on I want it to pop up dialog that will ask him the first time he eats on the day and then the app will notify him to eat every 3 hours from this hour. SO I tried to start this and it looks really hard. so far I got the notification and didn't figure how to fire the notification every 3 hours, this is my code:
import { Component } from '@angular/core';
import { NavController, NavParams, IonicPage , AlertController , Platform } from 'ionic-angular';
import { LocalNotifications } from '@ionic-native/local-notifications';
@IonicPage()
@Component({
selector: 'page-settings',
templateUrl: 'settings.html'
})
export class Settings {
mealNotifierToggle : boolean = false ;
constructor(public navCtrl: NavController, public navParams: NavParams , private plt: Platform,
private localNotifications: LocalNotifications) {
}
scheduleNotification(){
this.localNotifications.schedule({
id: 1,
title: "Meal Time",
text: "Time to eat !",
every: 'minute'
});
}
}
There is any good explanations about how to save the 'Toggle' state even when the app is closed and how to fire the notification every 3 hours? An explanation for the pop up dialog will be sweet but I really want to try and do it by myself for now, If I won't succeed I will edit this question. Thanks a lot!
Matan
Upvotes: 0
Views: 621
Reputation: 1374
Take a look at the AlertController and especially the 'confirm' part.
Upvotes: 1