本文整理匯總了TypeScript中@ionic-native/calendar.Calendar類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Calendar類的具體用法?TypeScript Calendar怎麽用?TypeScript Calendar使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Calendar類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: addEvent
addEvent(gameInfo: any) {
console.log(gameInfo);
debugger;
const title = 'Game reminder: ' + gameInfo.player;
const notes = 'vs ' + gameInfo.opponent + ', ' + gameInfo.competition;
const startDate: Date = gameInfo.date.toDate();
const endDate = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate(),
startDate.getHours() + 2, startDate.getMinutes(), startDate.getSeconds());
console.log('startDate', startDate);
console.log('endDate', endDate);
// this.calendar.createEvent('Moj Komšija događaj', this.event.locationName, '', new Date(this.event.dateFrom), new Date(this.event.dateTo)).then(
// () => {
// this.toast.presentToast('Događaj je uspešno sačuvan u kalendaru telefona.')
// }, () => {
// this.createCalendarAlert('Greška', 'Došlo je do greške prilikom čuvanja događaja. Proverite da li aplikacija ima dozvoljen pristup kalendaru i pokušajte ponovo.');
// });
this.calendar.createEvent(title, '', notes, startDate, endDate)
.then(
() => {
console.log('event created');
this.showToast();
},
() => console.log('Error occured on creating event.')
);
}
示例2: addEvent
addEvent(gameInfo: any) {
const title = 'Report reminder: ' + gameInfo.player;
const notes = 'vs' + gameInfo.opponent + ', ' + gameInfo.competition;
const startDate: Date = gameInfo.date;
const endDate = new Date(startDate.getFullYear(), startDate.getMonth() + 1, startDate.getDate(),
startDate.getHours() + 2, startDate.getMinutes(), startDate.getSeconds());
return this.calendar.createEvent(title, null, notes, startDate, endDate);
}
示例3:
this.calendar.hasReadWritePermission().then((result) => {
if (result === false) {
this.calendar.requestReadWritePermission().then((v) => {
this.addEvent(gameInfo);
}, (r) => {
console.log("Rejected");
})
}
else {
this.addEvent(gameInfo);
}
});