diff --git a/Modules/Sources/Experiments/DefaultFeatureFlagService.swift b/Modules/Sources/Experiments/DefaultFeatureFlagService.swift index fa9ec1cac1b..dc29bb6e595 100644 --- a/Modules/Sources/Experiments/DefaultFeatureFlagService.swift +++ b/Modules/Sources/Experiments/DefaultFeatureFlagService.swift @@ -98,6 +98,8 @@ public struct DefaultFeatureFlagService: FeatureFlagService { return buildConfig == .localDeveloper || buildConfig == .alpha case .ciabBookings: return buildConfig == .localDeveloper || buildConfig == .alpha + case .pointOfSaleSurveys: + return buildConfig == .localDeveloper || buildConfig == .alpha default: return true } diff --git a/Modules/Sources/Experiments/FeatureFlag.swift b/Modules/Sources/Experiments/FeatureFlag.swift index c5734453d7a..baeada3cb49 100644 --- a/Modules/Sources/Experiments/FeatureFlag.swift +++ b/Modules/Sources/Experiments/FeatureFlag.swift @@ -203,4 +203,8 @@ public enum FeatureFlag: Int { /// Enables a new Bookings tab for CIAB sites /// case ciabBookings + + /// Enables surveys for potential and current POS merchants + /// + case pointOfSaleSurveys } diff --git a/WooCommerce/Classes/Notifications/LocalNotification.swift b/WooCommerce/Classes/Notifications/LocalNotification.swift index db769a58a0a..c1d6abb41ce 100644 --- a/WooCommerce/Classes/Notifications/LocalNotification.swift +++ b/WooCommerce/Classes/Notifications/LocalNotification.swift @@ -22,6 +22,7 @@ struct LocalNotification { case blazeNoCampaignReminder case blazeAbandonedCampaignCreationReminder case productImageBackgroundUpload + case pointOfSalePotentialMerchant case unknown(siteID: Int64) var identifier: String { @@ -32,6 +33,8 @@ struct LocalNotification { return "blaze_abandoned_campaign_reminder" case .productImageBackgroundUpload: return "product_image_background_upload" + case .pointOfSalePotentialMerchant: + return "point_of_sale_potential_merchant" case let .unknown(siteID): return "unknown_" + "\(siteID)" } @@ -95,6 +98,9 @@ extension LocalNotification { case .productImageBackgroundUpload: title = Localization.ProductImageBackgroundUpload.title body = Localization.ProductImageBackgroundUpload.body + case .pointOfSalePotentialMerchant: + title = Localization.PointOfSalePotentialMerchant.title + body = Localization.PointOfSalePotentialMerchant.body case .unknown: title = "" body = "" @@ -147,5 +153,17 @@ extension LocalNotification { comment: "Message on the local notification to inform the user about the background upload of product images." ) } + enum PointOfSalePotentialMerchant { + static let title = NSLocalizedString( + "localNotification.PointOfSalePotentialMerchant.title", + value: "Thinking about in-person sales?", + comment: "Title of the local notification sent to potential Point of Sale merchants" + ) + static let body = NSLocalizedString( + "localNotification.PointOfSalePotentialMerchant.body", + value: "Take a quick 2-minute survey to help us shape features you’ll love.", + comment: "Message body of the local notification sent to potential Point of Sale merchants" + ) + } } } diff --git a/WooCommerce/Classes/Notifications/PushNotificationsManager.swift b/WooCommerce/Classes/Notifications/PushNotificationsManager.swift index 49b17cc65ac..53c0d6d3d78 100644 --- a/WooCommerce/Classes/Notifications/PushNotificationsManager.swift +++ b/WooCommerce/Classes/Notifications/PushNotificationsManager.swift @@ -252,19 +252,24 @@ extension PushNotificationsManager { unregisterForRemoteNotifications() } - /// Handles a Notification while in Foreground Mode. Currently, only remote notifications are handled in the foreground. + /// Handles a notification while the app is in foreground /// - /// - Parameters: - /// - userInfo: The Notification's Payload - /// - completionHandler: A callback, to be executed on completion - /// - /// - Returns: True when handled. False otherwise + /// - Parameter notification: The delivered `UNNotification` + /// - Returns: `UNNotificationPresentationOptions` indicating how (if at all) the system should present its own UI for this notification /// @MainActor func handleNotificationInTheForeground(_ notification: UNNotification) async -> UNNotificationPresentationOptions { let content = notification.request.content + if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleSurveys) { + // Check if this is a local notification + if !content.isRemoteNotification { + // Display local notifications with banner and sound when app is in foreground + return [.banner, .sound] + } + } + guard applicationState == .active, content.isRemoteNotification, inAppNotices == true else { - // Local notifications are currently not handled when the app is in the foreground. + // Remote notifications not handled when the app is not active, or in-app notices are disabled return UNNotificationPresentationOptions(rawValue: 0) }