Skip to content

Conversation

bbirman
Copy link
Member

@bbirman bbirman commented Oct 8, 2025

Simulator.Screen.Recording.-.iPhone.16e.-.2025-10-08.at.14.57.34.mov

NSMutableArray *menuActions = [[NSMutableArray alloc] initWithCapacity:3];

// Don't show the change server option if there are no hosts to switch to.
SFManagedPreferences *managedPreferences = [SFManagedPreferences sharedPreferences];
Copy link
Member Author

Choose a reason for hiding this comment

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

I moved this check to just be around the “Choose Connection” option instead of the settings icon but that would just be for MDM. @wmathurin what do you think about having another property like showServerPicker on the login config in case an app wants to show the settings icon but hide the change server option? Here’s the existing configuration doc: https://developer.salesforce.com/docs/platform/mobile-sdk/guide/oauth-hide-gear-icon.html

@MainActor
public static func clearCache() async {
let dataStore = WKWebsiteDataStore.default()
let websiteDataTypes: Set<String> = [WKWebsiteDataTypeFetchCache, WKWebsiteDataTypeMemoryCache, WKWebsiteDataTypeDiskCache, WKWebsiteDataTypeOfflineWebApplicationCache]
Copy link
Member Author

Choose a reason for hiding this comment

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

I included any type that had cache in the name

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use: WKWebsiteDataStore.allWebsiteDataTypes() ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it okay that it would also include the cookies that we have the other method for? Having a way to get rid of everything sounds good to me

Copy link
Contributor

Choose a reason for hiding this comment

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

In my mind, it was about starting clean. Let me check the Android code.

Copy link
Contributor

Choose a reason for hiding this comment

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

On Android we are doing webView.clearCache(true) (see https://github.com/forcedotcom/SalesforceMobileSDK-Android/pull/2752/files#diff-2b4d6c9697f160bfbefe121309b911622ea530d287a7fbc780a872cfd75cd82aR247) which does not clear the cookies.

To do everything but the cookies we could do

let nonCookieDataTypes: Set<String> = [
    WKWebsiteDataTypeDiskCache,
    WKWebsiteDataTypeMemoryCache,
    WKWebsiteDataTypeLocalStorage,
    WKWebsiteDataTypeSessionStorage,
    WKWebsiteDataTypeIndexedDBDatabases,
    WKWebsiteDataTypeWebSQLDatabases,
    WKWebsiteDataTypeOfflineWebApplicationCache,
    WKWebsiteDataTypeServiceWorkerRegistrations
]```

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good, updated! I also changed the "Clear Cookies" option to use the method that clears the cookies regardless of the cookie management flag, I was thinking that would be better to make sure it starts clean like you said (let me know if you think I should change it back)

Copy link

github-actions bot commented Oct 8, 2025

1 Warning
⚠️ Static Analysis found an issue with one or more files you modified. Please fix the issue(s).

Clang Static Analysis Issues

File Type Category Description Line Col
SFUserAccountManager Nullability Memory error Null passed to a callee that requires a non-null 2nd parameter 1494 15
SFUserAccountManager Nullability Memory error Null passed to a callee that requires a non-null 2nd parameter 1509 15
SFUserAccountManager Nullability Memory error nil passed to a callee that requires a non-null 2nd parameter 2141 13

Generated by 🚫 Danger

[self restartAuthenticationForViewController:loginViewController];
}

- (void)loginViewControllerDidClearCache:(SFLoginViewController *)loginViewController {
Copy link
Member Author

@bbirman bbirman Oct 8, 2025

Choose a reason for hiding this comment

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

From this comment about reloading, I used the same restart method as the one that happens after the login host is changed

Copy link

codecov bot commented Oct 8, 2025

Codecov Report

❌ Patch coverage is 1.51515% with 65 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.32%. Comparing base (c83d097) to head (1649d0d).
⚠️ Report is 7 commits behind head on dev.

Files with missing lines Patch % Lines
...forceSDKCore/Classes/Login/SFLoginViewController.m 0.00% 41 Missing ⚠️
...ceSDKCore/Classes/Common/WebViewStateManager.swift 0.00% 12 Missing ⚠️
...SDKCore/Classes/UserAccount/SFUserAccountManager.m 0.00% 12 Missing ⚠️

❌ Your patch check has failed because the patch coverage (1.51%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #3940      +/-   ##
==========================================
- Coverage   63.46%   63.32%   -0.15%     
==========================================
  Files         250      250              
  Lines       22493    22548      +55     
==========================================
+ Hits        14276    14278       +2     
- Misses       8217     8270      +53     
Components Coverage Δ
Analytics 70.78% <ø> (ø)
Common 70.58% <ø> (-0.52%) ⬇️
Core 53.71% <1.51%> (-0.16%) ⬇️
SmartStore 73.66% <ø> (ø)
MobileSync 87.66% <ø> (ø)
Files with missing lines Coverage Δ
...ore/Classes/Login/SFSDKLoginViewControllerConfig.m 84.61% <100.00%> (+1.28%) ⬆️
...ceSDKCore/Classes/Common/WebViewStateManager.swift 31.70% <0.00%> (-13.13%) ⬇️
...SDKCore/Classes/UserAccount/SFUserAccountManager.m 39.20% <0.00%> (-0.44%) ⬇️
...forceSDKCore/Classes/Login/SFLoginViewController.m 11.06% <0.00%> (-1.76%) ⬇️

... and 4 files with indirect coverage changes

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

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