Skip to content

Conversation

@iamgabrielma
Copy link
Contributor

Closes WOOMOB-1528
Closes WOOMOB-1521

Description

This PR updates the trigger for the "current merchant" case, so it schedules it when the app is opened, rather than when POS is opened.

Changes

  • Moves survey scheduler checks from POSTabCoordinator to AppCoordinator
  • DI POSNotificationScheduling into EditableOrderViewModel
  • Adds unit tests

Testing information

  1. On a physical device, with notifications turned on, and in a US/UK store:
  2. Update POSNotificationScheduler.timeIntervalInSeconds to something like 5 seconds
  3. In AppCoordinator.schedulePOSSurveyNotificationIfNeeded add the following bit to clear any persisted state
private extension AppCoordinator {
    func schedulePOSSurveyNotificationIfNeeded() {
+        Task { @MainActor in
+          let action = AppSettingsAction.resetPOSSurveyNotificationScheduled { _ in }
+          stores.dispatch(action)
+        }
        Task { @MainActor in
            await POSNotificationScheduler(stores: stores).scheduleLocalNotificationIfEligible(for: .currentMerchant)

            let action = AppSettingsAction.setHasPOSBeenOpenedAtLeastOnce { _ in }
            stores.dispatch(action)
        }
    }
}
  1. Run the app, and open POS
  2. Remove the reset block we've just added to AppCoordinator.schedulePOSSurveyNotificationIfNeeded
  3. Re-run the app and wait 5 seconds
  4. You should see the notification appear

@iamgabrielma iamgabrielma added this to the 23.6 milestone Oct 21, 2025
@iamgabrielma iamgabrielma added type: task An internally driven task. feature: POS labels Oct 21, 2025
@iamgabrielma iamgabrielma requested a review from staskus October 21, 2025 02:58
@iamgabrielma iamgabrielma changed the title [Woo POS][Surveys] [Woo POS][Surveys] Schedule notification trigger on opening app, rather than on opening POS Oct 21, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Oct 21, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr16261-3571be9
Version23.5
Bundle IDcom.automattic.alpha.woocommerce
Commit3571be9
Installation URL6gq6l2knr5vng
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Copy link
Contributor

@staskus staskus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to keep setHasPOSBeenOpenedAtLeastOnce in POSTabCoordinator but move scheduleLocalNotificationIfEligible to app coordinator.

Task { @MainActor in
await POSNotificationScheduler(stores: stores).scheduleLocalNotificationIfEligible(for: .currentMerchant)

let action = AppSettingsAction.setHasPOSBeenOpenedAtLeastOnce { _ in }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we set POSBeenOpenedAtLeastOnce flag when opening the app, and not when opening the POS?

With this change, we can get a notification by opening the app twice.

As I understand, the desired behavior is to: show the notification after opening the app if POS was opened at least once

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're so right, I should've paid more attention 🙇. I've updated the logic on 3571be9

  • The 1st time they open the app (or after reset) when we perform the check for .currentMerchant this won't be scheduled as won't pass the guard for hasOpenedPOSAtLeastOnce
  • The merchant opens POS, which dispatches AppSettingsAction.setHasPOSBeenOpenedAtLeastOnce
  • The 2nd time they open the app, passes the guard for hasOpenedPOSAtLeastOnce and schedules the local notification.
  • The 3rd time they open the app, it will not pass the guard for isNotificationScheduled, so it won't be re-scheduled.

@iamgabrielma iamgabrielma requested a review from staskus October 22, 2025 03:20
Copy link
Contributor

@staskus staskus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fixes, @iamgabrielma! Now it is as expected 👍

Copy link
Contributor

@staskus staskus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as described 👍

My one suggestion is to also trigger potential merchant notification when tapping Collect Payment, not only Create Order. I think those IPP users are even more potential than those who just create an order.

@iamgabrielma iamgabrielma merged commit ae833e3 into trunk Oct 22, 2025
13 checks passed
@iamgabrielma iamgabrielma deleted the task/WOOMOB-1528-update-current-merchant-trigger branch October 22, 2025 07:50
@iamgabrielma
Copy link
Contributor Author

My one suggestion is to also trigger potential merchant notification when tapping Collect Payment, not only Create Order. I think those IPP users are even more potential than those who just create an order.

I agree, this was one of the first suggestions but we ended going with order creation (we still haven't got product feedback on the project). I'll raise it again as soon as we discuss next steps 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: POS type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants