Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
result => {
// get card ID
let cardId = this.card().idFormatted()
// get the last 5 digits of the card (with space)
let cardLastDigits = cardId.substring(cardId.length - 6)
// create the calendar event
Calendar.createEventInteractively(
`Myki card ${cardLastDigits} expires`,
null,
`Card number ${cardId}`,
this.card().expiry,
moment(this.card().expiry).add(1, 'days').toDate() // the calendar end date needs to be the "end of day"
).catch(() => {
// there was an error creating event, we probably don't have permission
let toast = this.toastCtrl.create({
position: 'top',
message: 'This app does not have calendar permissions. Please go to settings and enable calendar permissions for this app.',
duration: 3000
});
toast.present();
})
})
}
addReminder() {
Calendar.hasWritePermission().then(
result => {
if (!result)
// if we don't have calendar permissions, ask for it
Calendar.requestWritePermission().then(
() => {
// when we have permissions (or think we have permission), move on
return Promise.resolve()
}
)
})
.then(
result => {
// get card ID
let cardId = this.card().idFormatted()
// get the last 5 digits of the card (with space)
result => {
if (!result)
// if we don't have calendar permissions, ask for it
Calendar.requestWritePermission().then(
() => {
// when we have permissions (or think we have permission), move on
return Promise.resolve()
}
)
})
.then(