Skip to content

Conversation

@iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented Oct 9, 2025

Closes WOOMOB-1456

Description

This PR adds the feature flag for POS Surveys, as well as defines the LocalNotification case for the "potential merchant" case (unused). A potential merchant right now is just anybody that creates an order in the app, later on will narrow down the conditions further to send this notification.

Changes

We expand the current behavior of handleNotificationInTheForeground, which at the moment only handles remote push notifications, not local ones. This method is currently only used for tests, also I've confirmed with Kiwi how current Blaze notifications work at: p1760012173127899-slack-C03L1NF1EA3 just to be sure, and these only happen in the background.

Testing

The notification code is not currently used:

  1. Be sure you've given notification permissions to the app.
  2. Go to PaymentMethodsViewModel, and add a call to scheduleNotification() inside PaymentMethodsViewModel.trackFlowCompleted:
    /// Tracks the `paymentsFlowCompleted` event.
    ///
    func trackFlowCompleted(method: WooAnalyticsEvent.PaymentsFlow.PaymentMethod,
                            cardReaderType: WooAnalyticsEvent.PaymentsFlow.CardReaderType?) {
        let currencyFormatter = CurrencyFormatter(currencySettings: currencySettings)
        let amountNormalized = currencyFormatter.convertToDecimal(total) ?? 0

        let amountInSmallestUnit = amountNormalized
            .multiplying(by: NSDecimalNumber(value: currencySettings.currencyCode.smallestCurrencyUnitMultiplier))
            .intValue

+        scheduleNotification()
    private func scheduleNotification() {
        Task { @MainActor in
            let seconds = TimeInterval(3)
            let notification = LocalNotification(title: "Hello",
                                                 body: "Some more text",
                                                 scenario: .pointOfSalePotentialMerchant,
                                                 actions: nil,
                                                 userInfo: [:])
            let trigger = UNTimeIntervalNotificationTrigger(timeInterval: seconds, repeats: false)

            await ServiceLocator.pushNotesManager.requestLocalNotification(notification, trigger: trigger)
        }
    }
  1. On a physical device: Run the app > Orders > Create an Order > Collect the payment
  2. Upon success, the local notification will appear after 3 seconds

Screenshots

ScreenRecording_10-09-2025.19-20-50_1.MP4

@iamgabrielma iamgabrielma added type: task An internally driven task. feature: POS labels Oct 9, 2025
@iamgabrielma iamgabrielma added this to the 23.5 milestone Oct 9, 2025
@wpmobilebot
Copy link
Collaborator

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 Numberpr16229-4b81f10
Version23.4
Bundle IDcom.automattic.alpha.woocommerce
Commit4b81f10
Installation URL7po73m54msffg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@iamgabrielma iamgabrielma requested a review from staskus October 10, 2025 02:53
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.

Thanks! Clear start. Made one suggestion how to structure it going forward.

@MainActor
func handleNotificationInTheForeground(_ notification: UNNotification) async -> UNNotificationPresentationOptions {
let content = notification.request.content
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleSurveys) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if in this PR, but we could expand our LocalNotification definition that would also define how it needs to be handled, possibly through userInfo + helper extensions such as content.isRemoteNotification. Then, this handler method could be made tidier, and not contain feature flag or content.isRemoteNotification checks.

E.g

if content.showSystemNotification {
     
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review and suggestion!

Yes, this class will need some further updates when handling these, for example, one case I've already found is that if we call handleNotificationInTheForeground when the merchant is in POS mode it will not trigger anything, because tabBarController is not in the window hierarchy due POS being presented full-screen, so we need to reach to the topmost VC instead. Feature flag will also be called outside on some sort of eligibility checker before reaching this point 👍

@iamgabrielma iamgabrielma merged commit 10643d6 into trunk Oct 10, 2025
23 of 24 checks passed
@iamgabrielma iamgabrielma deleted the task/WOOMOB-1456-pos-surveys-ff branch October 10, 2025 08:56
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