diff --git a/src/constants/accountView.ts b/src/constants/accountView.ts index 3953b264..6fee50ff 100644 --- a/src/constants/accountView.ts +++ b/src/constants/accountView.ts @@ -57,9 +57,12 @@ export const ACCOUNT_VIEW_CONSTANTS = { // Notification messages NOTIFICATIONS: { NEW_ACTIVITY_INFO: ` - This will only notify you when there is new relevant activity for you personally. - Note that it runs on your device and many factors may affect delivery, - so if you want a reliable but simple daily notification then choose a 'Reminder'. + This will notify you with an app message when there is new relevant activity for you personally. + Do you want more details? + `, + NEW_ACTIVITY_SMS_INFO: ` + This is opt-in: by turning it on you agree to receive text messages when there is new relevant activity for you personally. + Standard message and data rates may apply, and you can turn it off at any time. Do you want more details? `, REMINDER_INFO: ` diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index 15918df9..affc3938 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -143,24 +143,48 @@ -
- -
+ + +
+
New Activity Notification
+

+ Get told about new relevant activity for you. Choose a delivery + channel below -- you can turn on either one, or both. +

+
+ + +
+ +
+
@@ -178,7 +202,7 @@ >
-
+
@@ -191,10 +215,75 @@ class="w-full text-md bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-4 py-2 rounded-md" @click="editNewActivityNotification" > - Edit New Activity Notification… + Edit In-App Time…
+ + +
+ +
+
+ +
+ +
+
+
+
+
+
+
+ Time: + {{ notifyingNewActivitySmsTime.replace(" ", " ") }} +
+
+ Text to: + {{ notifyingNewActivitySmsPhone || "(number not set)" }} +
+
+
+ +
+
+
Troubleshoot your notifications… @@ -546,7 +635,8 @@
-
+ +

Notification Push Server

@@ -931,6 +1021,12 @@ export default class AccountViewView extends Vue { // Notification properties notifyingNewActivity: boolean = false; notifyingNewActivityTime: string = ""; + // SMS delivery channel for New Activity (opt-in). MOCK-UP: state is currently + // component-local. TODO: persist via settings + register the number and time + // with the notify-api (SMS registration/verification flow). + notifyingNewActivitySms: boolean = false; + notifyingNewActivitySmsTime: string = ""; + notifyingNewActivitySmsPhone: string = ""; notifyingReminder: boolean = false; notifyingReminderMessage: string = ""; notifyingReminderTime: string = ""; @@ -1216,9 +1312,11 @@ export default class AccountViewView extends Vue { } } - async showNewActivityNotificationInfo(): Promise { + async showNewActivityNotificationInfo(isSms: boolean): Promise { this.notify.confirm( - ACCOUNT_VIEW_CONSTANTS.NOTIFICATIONS.NEW_ACTIVITY_INFO, + isSms + ? ACCOUNT_VIEW_CONSTANTS.NOTIFICATIONS.NEW_ACTIVITY_SMS_INFO + : ACCOUNT_VIEW_CONSTANTS.NOTIFICATIONS.NEW_ACTIVITY_INFO, async () => { await (this.$router as Router).push({ name: "help-notification-types", @@ -1266,6 +1364,89 @@ export default class AccountViewView extends Vue { } } + /** + * Toggle the SMS delivery channel for New Activity notifications. + * + * MOCK-UP: reuses the time-picker dialog so the UI behaves like the in-app + * channel, but the picked time is only held in component state for now. + * + * TODO (notify-api wiring): on enable, ensure the user has a verified phone + * number, then POST the SMS-notification preference to the notify-api with + * SMS-specific params (channel="sms", phoneNumber, sendTime) -- the same + * alert as the in-app channel, delivered by a different transport. On + * disable, tell the notify-api to remove the SMS preference. + */ + async showNewActivitySmsNotificationChoice(): Promise { + if (!this.notifyingNewActivitySms) { + ( + this.$refs.pushNotificationPermission as PushNotificationPermission + ).open( + DAILY_CHECK_TITLE, + async (success: boolean, timeText: string) => { + if (success) { + // TODO: verify phone number + register SMS preference with notify-api + this.notifyingNewActivitySms = true; + this.notifyingNewActivitySmsTime = timeText; + } + }, + { skipSchedule: true }, + ); + } else { + // TODO: remove SMS preference from notify-api + this.notifyingNewActivitySms = false; + this.notifyingNewActivitySmsTime = ""; + } + } + + /** + * Edit the time for the SMS delivery channel. + * + * MOCK-UP: updates component state only. TODO: PUT the updated sendTime to + * the notify-api SMS preference. + */ + async editNewActivitySmsNotification(): Promise { + const dialog = this.$refs + .pushNotificationPermission as PushNotificationPermission; + + dialog.open( + DAILY_CHECK_TITLE, + async (success: boolean, timeText: string) => { + if (!success) return; + // TODO: PUT updated sendTime to notify-api SMS preference + this.notifyingNewActivitySmsTime = timeText; + this.notify.success( + "New Activity SMS time updated.", + TIMEOUTS.STANDARD, + ); + }, + { skipSchedule: true }, + ); + + // Pre-populate the dialog with the current SMS time + setTimeout(() => { + const timeMatch = this.notifyingNewActivitySmsTime.match( + /(\d+):(\d+)\s*(AM|PM)/i, + ); + if (timeMatch) { + let hour = parseInt(timeMatch[1], 10); + const minute = timeMatch[2]; + const isAm = timeMatch[3].toUpperCase() === "AM"; + if (hour === 12) { + hour = 12; + } else if (hour > 12) { + hour = hour - 12; + } + const dialogComponent = + dialog as unknown as PushNotificationPermissionRef; + if (dialogComponent) { + dialogComponent.hourInput = hour.toString(); + dialogComponent.minuteInput = minute; + dialogComponent.hourAm = isAm; + } + } + }, 150); + } + /** * Configure native fetcher, sync starred plans, and schedule API-driven dual notification. */ diff --git a/src/views/HelpNotificationTypesView.vue b/src/views/HelpNotificationTypesView.vue index 35242a35..9516b851 100644 --- a/src/views/HelpNotificationTypesView.vue +++ b/src/views/HelpNotificationTypesView.vue @@ -39,31 +39,32 @@ something, so you can record thanks in here.

- This is a reliable message, but it doesn't contain any details about + This is your own message activated in the app, but it doesn't contain any details about activity that might be especially interesting to you. + Note that the timing is not precise: the device may deliver it a bit later than scheduled.

-

New Activity Notifications

+

New Activity Notifications -- In App

- The New Activity Notification will be sent to you when there is new, relevant activity + The New Activity Notification will be activated in your app when there is new, relevant activity for you. It will only trigger if something involves you or a project of interest; it will not bug you for other, general activity.

+
+ +

New Activity Notifications -- Texts From A Server

+

- This type is not as reliable as a Reminder Notification because mobile devices often - suppress such notifications to save battery. (If you want to quickly check for relevant - activity daily, use the Reminder Notification and open the app and look for a large green - button that points out new activity that is personal to you. We are working on other - ways to notify you more reliably. - - go here to follow us or contact us - - .) + This New Activity Notification SMS will be sent to you when there is new, relevant activity + for you. + It will only trigger if something involves you or a project of interest; it will not + bug you for other, general activity.

+