Mobile Solutions

How to implement the Mobile Safari Extension

7min

Overview

This will be a brief walkthrough for importing our iOS Safari Extension into an existing iOS App. After Wildfire builds the extension to agreed specifications we will provide an Xcode project that includes a placeholder host app and the Safari Extension App. This can be used for testing the extension without requiring the extension to be added into your project.

If you are interested in the Wildfire's turn-key Mobile Safari Extension please contact your client success representative.

Add a new target in the destination project

We will start by opening up your existing Xcode project and create a new Target.

File > New > Target...

Document image


Select "Safari Extension" from the list of iOS targets.

Document image


Name your new target, this can follow your conventions and be anything.

Document image


Remove the template files

Next, we will remove most of the new files created and replace them with the ones from the extension project.

Delete all of the files within the Resources Directory and the SafariWebExtensionHandler

Document image


Add the extension files to your project

From the source project copy SafariWebExtensionHandler.swift into your new extension directory. Select 'Don't Create Bridge' if the Objective-C bridge dialog appears.

Now select all of the items inside the Resources directory from the source project and copy them into the Resources Directory of your project.

In the next window, be sure to select the following options:

  • Copy items if needed
  • Create folder references
  • Select only the extension in the targets list.
Document image


Configurations

There are a few configuration settings the host app can send over to the extension to change behavior and help manage user attribution. These are sent to the JavaScript side of the extension by the Native Extension app. Found within SafariWebExtensionHandler.swift.

1. GET_USER_ID(Required) is a unique identifier created by the host app, used to identify which one of your users is using the extension.

2. GET_LAST_LINK_TIMESTAMP(Optional) is used if you are presenting your own affiliate links within the host app, setting this to the current time will prevent the extension from presenting an EMA on the next loaded website.

3. IS_EXTENSION_ENABLED(Required) is a boolean used to enable or disable the extension, this must be set to true for the user to make use of the extension.

4. IS_COUPON_ENABLED(Required) is a boolean used to enable or disable the Couponator functionality, this must be set to true for the user to be presented with available coupons on eligible checkout pages.

5. GET_SPLIT_AMOUNT(Required) is used to control the visuals for how much the end user can earn on a transaction. This is a float that can be between 0 and 1. 

1 = 100% of earnings go to the user.

.5 = 50% of earnings go to the user.

.3 = 30% of earnings go to the user.

These values can either be hard-coded into SafariWebExtensionHandler.swift or set using an app group shared by the extension and the host app.

Success

You have successfully added the extension into your app. It will automatically be installed when the project is run on either the simulator or a physical device.

Note: Extensions must be enabled in Safari before Safari will allow them to launch. This is done by selecting 'Manage Extensions' from the pop-up menu within safari.