Skip to content

Add foregroundRegistrationMode enum to re-register all users on app foreground#4030

Open
sfdctaka wants to merge 3 commits intoforcedotcom:devfrom
sfdctaka:reregisterNotification
Open

Add foregroundRegistrationMode enum to re-register all users on app foreground#4030
sfdctaka wants to merge 3 commits intoforcedotcom:devfrom
sfdctaka:reregisterNotification

Conversation

@sfdctaka
Copy link
Copy Markdown
Contributor

@sfdctaka sfdctaka commented May 6, 2026

  1. New enum PushNotificationForegroundRegistrationMode (before PushNotificationManagerError):
  • .none — no re-registration on foreground
  • .currentUser — re-register only the current user (preserves pre-14.0 behavior)
  • .allUsers — re-register all logged-in users (new default)
  • Doc comment calls out the Publisher/per-login billing concern explicitly
  1. New property foregroundRegistrationMode: .allUsers replaces the old Bool
  2. Deprecated shim for registerOnForeground: Bool — kept as a computed property that maps to the new enum, so existing apps don't break with a compiler error, just a deprecation warning
  3. onAppWillEnterForeground — now switches on the mode: iterates UserAccountManager.shared.userAccounts() for .allUsers, falls back to current-user-only for .currentUser

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

TestsPassedSkippedFailed ❌️
AuthFlowTester UI Test Results all1 ran1 ❌
TestResult
AuthFlowTester UI Test Results all
AuthFlowTesterUITests.xctest
LegacyLoginTests.testCAOpaque_DefaultScopes_WebServerFlow()❌ failure

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.26%. Comparing base (3cdaf5f) to head (8222a71).

Files with missing lines Patch % Lines
...ses/PushNotification/PushNotificationManager.swift 75.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #4030      +/-   ##
==========================================
- Coverage   70.34%   68.26%   -2.09%     
==========================================
  Files         245      245              
  Lines       21449    21457       +8     
==========================================
- Hits        15089    14647     -442     
- Misses       6360     6810     +450     
Components Coverage Δ
Analytics 70.78% <ø> (ø)
Common 70.79% <ø> (-0.19%) ⬇️
Core 61.75% <75.00%> (-3.23%) ⬇️
SmartStore 73.44% <ø> (ø)
MobileSync 88.79% <ø> (ø)
Files with missing lines Coverage Δ
...ses/PushNotification/PushNotificationManager.swift 83.54% <75.00%> (+1.48%) ⬆️

... and 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

TestsPassed ☑️SkippedFailed ❌️
SalesforceSDKCore iOS ^26 Test Results631 ran630 ✅1 ❌
TestResult
SalesforceSDKCore iOS ^26 Test Results
SFUserAccountManagerTests.testAuthHandler❌ failure

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

TestsPassed ✅SkippedFailed
SalesforceSDKCore iOS ^18 Test Results631 ran631 ✅
TestResult
No test annotations available

@sfdctaka sfdctaka marked this pull request as ready for review May 7, 2026 22:25
@sfdctaka sfdctaka changed the title [DRAFT] Add foregroundRegistrationMode enum to re-register all users on app foreground Add foregroundRegistrationMode enum to re-register all users on app foreground May 7, 2026
@sfdctaka sfdctaka requested a review from bbirman May 7, 2026 22:26
pushNotificationManager.foregroundRegistrationMode = .currentUser
mockRestClient.jsonResponse = """
{"success": true, "id": "test-sf-id"}
""".data(using: .utf8)!
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: even though it's just test code, I'd like to avoid force unwraps (here and in test_givenModeAllUsers_whenAppEntersForeground_thenAllUsersAreRegistered)


@available(*, deprecated, renamed: "foregroundRegistrationMode",
message: "Use foregroundRegistrationMode instead. Set .none for false, .allUsers for true.")
public var registerOnForeground: Bool {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice way to have a migration from the old to new property!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants