Skip to content

Commit 10643d6

Browse files
authored
[Woo POS][Surveys] Add feature flag. Define "potential merchant" notification (#16229)
2 parents 4bfc20a + 4b81f10 commit 10643d6

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

Modules/Sources/Experiments/DefaultFeatureFlagService.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
9898
return buildConfig == .localDeveloper || buildConfig == .alpha
9999
case .ciabBookings:
100100
return buildConfig == .localDeveloper || buildConfig == .alpha
101+
case .pointOfSaleSurveys:
102+
return buildConfig == .localDeveloper || buildConfig == .alpha
101103
default:
102104
return true
103105
}

Modules/Sources/Experiments/FeatureFlag.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,8 @@ public enum FeatureFlag: Int {
203203
/// Enables a new Bookings tab for CIAB sites
204204
///
205205
case ciabBookings
206+
207+
/// Enables surveys for potential and current POS merchants
208+
///
209+
case pointOfSaleSurveys
206210
}

WooCommerce/Classes/Notifications/LocalNotification.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct LocalNotification {
2222
case blazeNoCampaignReminder
2323
case blazeAbandonedCampaignCreationReminder
2424
case productImageBackgroundUpload
25+
case pointOfSalePotentialMerchant
2526
case unknown(siteID: Int64)
2627

2728
var identifier: String {
@@ -32,6 +33,8 @@ struct LocalNotification {
3233
return "blaze_abandoned_campaign_reminder"
3334
case .productImageBackgroundUpload:
3435
return "product_image_background_upload"
36+
case .pointOfSalePotentialMerchant:
37+
return "point_of_sale_potential_merchant"
3538
case let .unknown(siteID):
3639
return "unknown_" + "\(siteID)"
3740
}
@@ -95,6 +98,9 @@ extension LocalNotification {
9598
case .productImageBackgroundUpload:
9699
title = Localization.ProductImageBackgroundUpload.title
97100
body = Localization.ProductImageBackgroundUpload.body
101+
case .pointOfSalePotentialMerchant:
102+
title = Localization.PointOfSalePotentialMerchant.title
103+
body = Localization.PointOfSalePotentialMerchant.body
98104
case .unknown:
99105
title = ""
100106
body = ""
@@ -147,5 +153,17 @@ extension LocalNotification {
147153
comment: "Message on the local notification to inform the user about the background upload of product images."
148154
)
149155
}
156+
enum PointOfSalePotentialMerchant {
157+
static let title = NSLocalizedString(
158+
"localNotification.PointOfSalePotentialMerchant.title",
159+
value: "Thinking about in-person sales?",
160+
comment: "Title of the local notification sent to potential Point of Sale merchants"
161+
)
162+
static let body = NSLocalizedString(
163+
"localNotification.PointOfSalePotentialMerchant.body",
164+
value: "Take a quick 2-minute survey to help us shape features you’ll love.",
165+
comment: "Message body of the local notification sent to potential Point of Sale merchants"
166+
)
167+
}
150168
}
151169
}

WooCommerce/Classes/Notifications/PushNotificationsManager.swift

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,19 +252,24 @@ extension PushNotificationsManager {
252252
unregisterForRemoteNotifications()
253253
}
254254

255-
/// Handles a Notification while in Foreground Mode. Currently, only remote notifications are handled in the foreground.
255+
/// Handles a notification while the app is in foreground
256256
///
257-
/// - Parameters:
258-
/// - userInfo: The Notification's Payload
259-
/// - completionHandler: A callback, to be executed on completion
260-
///
261-
/// - Returns: True when handled. False otherwise
257+
/// - Parameter notification: The delivered `UNNotification`
258+
/// - Returns: `UNNotificationPresentationOptions` indicating how (if at all) the system should present its own UI for this notification
262259
///
263260
@MainActor
264261
func handleNotificationInTheForeground(_ notification: UNNotification) async -> UNNotificationPresentationOptions {
265262
let content = notification.request.content
263+
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleSurveys) {
264+
// Check if this is a local notification
265+
if !content.isRemoteNotification {
266+
// Display local notifications with banner and sound when app is in foreground
267+
return [.banner, .sound]
268+
}
269+
}
270+
266271
guard applicationState == .active, content.isRemoteNotification, inAppNotices == true else {
267-
// Local notifications are currently not handled when the app is in the foreground.
272+
// Remote notifications not handled when the app is not active, or in-app notices are disabled
268273
return UNNotificationPresentationOptions(rawValue: 0)
269274
}
270275

0 commit comments

Comments
 (0)