This open-source project provides support for opening links in Firefox for iOS. There are classes (for Objective-C and Swift), along with a sample project that uses them, available for reference and use.
The OpenInFirefoxControllerSwift
and OpenInFirefoxControllerObjC
classes provide methods that handle the making of custom URI schemes, checking if Firefox is installed on the device and opening the URL in Firefox. Callback URL support in the browser UI will be provided in the near future. We have provided Swift and Objective-C implementations of these classes to accommodate your language of choice.
isFirefoxInstalled
: returns true if Firefox is installedopenInFirefox
: opens the specified URL in Firefox; used with or without the following:callbackScheme
: the URL to which a callback is sent; you can define your app's custom URI scheme in a class variable calledmyAppScheme
at the top of both class files.
Firefox uses a single URI scheme, firefox://
. This scheme can accept the following query parameters:
url
: (required) the URL to open in Firefox.x-source
: (optional) the app's custom URI scheme, specified inmyAppScheme
.x-source-name
: (optional; required ifx-source
is specified) the app name to where the calling app returns; make sure to update your app'sCFBundleDisplayName
in itsInfo.plist
file or specify a custom name in the class file.
For Example:
- URL with
x-source
andx-source-name
specified:
firefox://x-callback-url/open/?x-source=firefoxopeninfirefoxclient://&url=https%253A%252F%252Fwww.mozilla.org%252Fen-US%252Fnewsletter%252Fios%252F&x-source-name=OpenInFirefoxClient
- URL with only
url
specified:
firefox://open-url?url=https%253A%252F%252Fwww.mozilla.org%252Fen-US%252Fnewsletter%252Fios%252F
- Download the class file in the language of your choice:
- Swift: OpenInFirefoxControllerSwift.swift
- Objective-C: OpenInFirefoxControllerObjC.m, OpenInFirefoxControllerObjC.h
- Update your app's custom URI scheme for callbacks:
- Make sure to register a custom URI scheme for your app and update the
myAppScheme
variable (Swift, Objective-C) in the class file of your choice.
- Call methods to open links in Firefox:
Learn more about how to contribute to this project: Firefox for iOS official repo