fix(notifications): New Activity dual-only; separate reminder IDs (Option A + 6.3)
- PushNotificationPermission: on native, when enabling New Activity (DAILY_CHECK_TITLE), skip scheduleDailyNotification so only AccountViewView's scheduleNewActivityDualNotification runs (dual schedule only). Daily Reminder still uses single reminder path. - Add reminderIds.ts with REMINDER_ID_DAILY_REMINDER and REMINDER_ID_NEW_ACTIVITY; NativeNotificationService uses the former. - Export reminder IDs from notifications index. Fixes "always fires / can't turn off" by avoiding a second, uncancellable single reminder for New Activity.
This commit is contained in:
@@ -758,17 +758,35 @@ export default class PushNotificationPermission extends Vue {
|
|||||||
time24h,
|
time24h,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Determine title and body based on pushType
|
// Option A: For New Activity we do not schedule the single daily reminder here.
|
||||||
const title =
|
// AccountViewView's callback will call scheduleNewActivityDualNotification(timeText),
|
||||||
this.pushType === this.DAILY_CHECK_TITLE
|
// which uses the dual schedule (prefetch + notify) only. This keeps the two notification
|
||||||
? "Daily Check-In"
|
// types separate and avoids a second, uncancellable reminder.
|
||||||
: "Daily Reminder";
|
if (this.pushType === this.DAILY_CHECK_TITLE) {
|
||||||
const body =
|
logger.info(
|
||||||
this.pushType === this.DIRECT_PUSH_TITLE
|
"[PushNotificationPermission] New Activity: skipping single reminder schedule; parent will schedule dual notification",
|
||||||
? this.messageInput || this.notificationMessagePlaceholder
|
);
|
||||||
: "Time to check your TimeSafari activity";
|
const timeText = this.notificationTimeText;
|
||||||
|
await this.$saveSettings({ notifyingNewActivityTime: timeText });
|
||||||
|
logger.debug(
|
||||||
|
"[PushNotificationPermission] Settings saved: notifyingNewActivityTime",
|
||||||
|
);
|
||||||
|
this.$notify(
|
||||||
|
{
|
||||||
|
group: "alert",
|
||||||
|
type: "success",
|
||||||
|
title: NOTIFY_PUSH_SUCCESS.title,
|
||||||
|
text: NOTIFY_PUSH_SUCCESS.message,
|
||||||
|
},
|
||||||
|
PUSH_NOTIFICATION_TIMEOUT_LONG,
|
||||||
|
);
|
||||||
|
this.callback(true, timeText, this.messageInput);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Schedule notification
|
// Daily Reminder: schedule the single daily notification (native only).
|
||||||
|
const title = "Daily Reminder";
|
||||||
|
const body = this.messageInput || this.notificationMessagePlaceholder;
|
||||||
logger.info(
|
logger.info(
|
||||||
"[PushNotificationPermission] Scheduling native notification:",
|
"[PushNotificationPermission] Scheduling native notification:",
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
import { Capacitor } from "@capacitor/core";
|
import { Capacitor } from "@capacitor/core";
|
||||||
import { DailyNotification } from "@/plugins/DailyNotificationPlugin";
|
import { DailyNotification } from "@/plugins/DailyNotificationPlugin";
|
||||||
|
import { REMINDER_ID_DAILY_REMINDER } from "./reminderIds";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extended type for DailyNotification that includes the actual Swift implementation
|
* Extended type for DailyNotification that includes the actual Swift implementation
|
||||||
@@ -44,10 +45,10 @@ export class NativeNotificationService implements NotificationServiceInterface {
|
|||||||
private readonly platformName = "native";
|
private readonly platformName = "native";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stable schedule/reminder ID used for schedule, cancel, and getStatus.
|
* Stable schedule/reminder ID for the Daily Reminder feature only.
|
||||||
* Same value on iOS and Android (plugin v1.1.2+ fixes Android reschedule with custom id).
|
* New Activity uses the dual schedule (scheduleDualNotification) and does not use this ID.
|
||||||
*/
|
*/
|
||||||
private readonly reminderId = "daily_timesafari_reminder";
|
private readonly reminderId = REMINDER_ID_DAILY_REMINDER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures only one scheduleDailyNotification runs at a time (no rapid successive plugin calls).
|
* Ensures only one scheduleDailyNotification runs at a time (no rapid successive plugin calls).
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ export {
|
|||||||
} from "./dualScheduleConfig";
|
} from "./dualScheduleConfig";
|
||||||
export type { DualScheduleConfigInput } from "./dualScheduleConfig";
|
export type { DualScheduleConfigInput } from "./dualScheduleConfig";
|
||||||
|
|
||||||
|
export {
|
||||||
|
REMINDER_ID_DAILY_REMINDER,
|
||||||
|
REMINDER_ID_NEW_ACTIVITY,
|
||||||
|
} from "./reminderIds";
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
NotificationServiceInterface,
|
NotificationServiceInterface,
|
||||||
DailyNotificationOptions,
|
DailyNotificationOptions,
|
||||||
|
|||||||
13
src/services/notifications/reminderIds.ts
Normal file
13
src/services/notifications/reminderIds.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Stable reminder/schedule IDs for native daily notifications.
|
||||||
|
* Keeps Daily Reminder and New Activity distinct so we can support both on
|
||||||
|
* and cancel only one. New Activity uses the dual schedule (scheduleDualNotification)
|
||||||
|
* only; this ID is for reference/future use (e.g. if we ever add a single-reminder
|
||||||
|
* fallback for New Activity).
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** ID for the single daily reminder (Daily Reminder feature). Used by NativeNotificationService. */
|
||||||
|
export const REMINDER_ID_DAILY_REMINDER = "daily_timesafari_reminder";
|
||||||
|
|
||||||
|
/** ID for New Activity. Not used for scheduling (we use dual schedule only); kept for clarity and future use. */
|
||||||
|
export const REMINDER_ID_NEW_ACTIVITY = "new_activity_timesafari";
|
||||||
Reference in New Issue
Block a user