Add a browser setting to Firefox Lockwise
These instructions are for developers wanting to add another browser setting so when users tap to open an entry's URL it will be sent to the web browser of their choice.
- Find and add the query scheme the new browser has registered to
LSApplicationQueriesSchemes
inCommon/Resources/Info.plist
. For example we'll use DuckDuckGo:
<string>ddgQuickLink</string>
- Then add a new case to
PreferredBrowserSetting
inExternalLinkAction.swift
:
swift
case DuckDuckGo
- Define that new case in the
getPreferredBrowserDeeplink
switch statement and return the string with that new query scheme as the expected URL syntax. Keep in mind you may need to encode the URLs and test some links to make sure they open as expected on a real device with the browser installed:
swift
case .DuckDuckGo:
return URL(string: "ddgQuickLink://\(url)")
- Add a constant (string) for the name of the browser (this will be used for the setting) to
Common/Resources/Constants.swift
:
swift
static let settingsBrowserDuckDuckGo = NSLocalizedString("settings.browser.duckduckgo", value: "Duck Duck Go", comment: "Duck Duck Go Browser")
- Then include the constant (name of the browser) to the case in the
toString()
function back inAction/ExternalLinkAction.swift
:
swift
case .DuckDuckGo:
return Constant.string.settingsBrowserDuckDuckGo
- Also add the name constant to the
initialSettings
variable inPresenter/PreferredBrowserSettingPresenter.swift
so thePreferredBrowserSettingPresenter
class can mark the browser as "checked" when selected:
swift
lazy var initialSettings = [
CheckmarkSettingCellConfiguration(text: Constant.string.settingsBrowserDuckDuckGo,
valueWhenChecked: PreferredBrowserSetting.DuckDuckGo),
That's it!
If you'd like to contribute a patch with the above, or anything else, please read our contributing guidelines.