本文整理汇总了TypeScript中@ionic-native/local-notifications.LocalNotifications类的典型用法代码示例。如果您正苦于以下问题:TypeScript LocalNotifications类的具体用法?TypeScript LocalNotifications怎么用?TypeScript LocalNotifications使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LocalNotifications类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Date
this.platform.ready().then(()=>{
this.localNotifications.schedule({
id: 1,
title: 'TrackoMed',
text: 'Sleep Time',
data: { mydata: 'Have you Slept Yet?' },
icon: '../../icon.png',
at: new Date(new Date().getTime() + 2 * 1000)
});
});
示例2:
this.platform.ready().then((readySource) => {
this.localNotifications.on('click', (notification, state) => {
let json = JSON.parse(notification.data);
let alert = alertCtrl.create({
title: notification.title,
subTitle: json.mydata
});
alert.present();
})
});
示例3: addFavorite
addFavorite(id: number): boolean {
if (!this.isFavorite(id)) {
this.favorites.push(id);
this.storage.set('favorites', this.favorites);
// Schedule a single notification
this.localNotifications.schedule({
id: id,
text: 'Dish ' + id + 'added as a favorite successfully'
});
}
console.log('favorites', this.favorites);
return true;
}
示例4: setInterval
this.interval = setInterval(() => {
this.now = new Date();
if (this.notifications) {
let { period, timeLeft } = this.getCurrentClassInfo();
if (period) {
this.notif.schedule({
id: 0,
title: period.name,
text: `${timeLeft} mins remaining`,
badge: timeLeft
});
}
}
}, 5000);