You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
iOS: Handle foreground notifications
This commit is contained in:
@@ -20,6 +20,11 @@ class AlarmService {
|
||||
return this.logger_;
|
||||
}
|
||||
|
||||
static setInAppNotificationHandler(v) {
|
||||
this.inAppNotificationHandler_ = v;
|
||||
if (this.driver_.setInAppNotificationHandler) this.driver_.setInAppNotificationHandler(v);
|
||||
}
|
||||
|
||||
static async garbageCollect() {
|
||||
this.logger().info('Garbage collecting alarms...');
|
||||
|
||||
@@ -56,16 +61,6 @@ class AlarmService {
|
||||
let alarm = noteId ? await Alarm.byNoteId(noteId) : null;
|
||||
let clearAlarm = false;
|
||||
|
||||
const makeNotificationFromAlarm = (alarm) => {
|
||||
const output = {
|
||||
id: alarm.id,
|
||||
date: new Date(note.todo_due),
|
||||
title: note.title.substr(0,128),
|
||||
}
|
||||
if (note.body) output.body = note.body.substr(0,512);
|
||||
return output;
|
||||
}
|
||||
|
||||
if (isDeleted ||
|
||||
!Note.needAlarm(note) ||
|
||||
(alarm && alarm.trigger_time !== note.todo_due))
|
||||
@@ -80,7 +75,7 @@ class AlarmService {
|
||||
// For non-persistent notifications however we need to check that the notification has been set because, for example,
|
||||
// if the app has just started the notifications need to be set again. so we do this below.
|
||||
if (!driver.hasPersistentNotifications() && !driver.notificationIsSet(alarm.id)) {
|
||||
const notification = makeNotificationFromAlarm(alarm);
|
||||
const notification = await Alarm.makeNotification(alarm, note);
|
||||
this.logger().info('Scheduling (non-persistent) notification for note ' + note.id, notification);
|
||||
driver.scheduleNotification(notification);
|
||||
}
|
||||
@@ -104,7 +99,7 @@ class AlarmService {
|
||||
// Reload alarm to get its ID
|
||||
alarm = await Alarm.byNoteId(note.id);
|
||||
|
||||
const notification = makeNotificationFromAlarm(alarm);
|
||||
const notification = await Alarm.makeNotification(alarm, note);
|
||||
this.logger().info('Scheduling notification for note ' + note.id, notification);
|
||||
await driver.scheduleNotification(notification);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user