Skip to content

Latest commit

 

History

History
49 lines (32 loc) · 2.06 KB

add-a-browser.md

File metadata and controls

49 lines (32 loc) · 2.06 KB

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.

  1. Find and add the query scheme the new browser has registered to LSApplicationQueriesSchemes in Common/Resources/Info.plist. For example we'll use DuckDuckGo:
<string>ddgQuickLink</string>
  1. Then add a new case to PreferredBrowserSetting in ExternalLinkAction.swift:
case DuckDuckGo
  1. 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:
case .DuckDuckGo:
  return URL(string: "ddgQuickLink://\(url)")
  1. Add a constant (string) for the name of the browser (this will be used for the setting) to Common/Resources/Constants.swift:
static let settingsBrowserDuckDuckGo = NSLocalizedString("settings.browser.duckduckgo", value: "Duck Duck Go", comment: "Duck Duck Go Browser")
  1. Then include the constant (name of the browser) to the case in the toString() function back in Action/ExternalLinkAction.swift:
case .DuckDuckGo:
  return Constant.string.settingsBrowserDuckDuckGo
  1. Also add the name constant to the initialSettings variable in Presenter/PreferredBrowserSettingPresenter.swift so the PreferredBrowserSettingPresenter class can mark the browser as "checked" when selected:
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.