Mobile Solutions

How to implement the Mobile Safari Extension

18min
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 an example 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 select "safari extension" from the list of ios targets name your new target, this can follow your conventions and be anything 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 add the extension files to your project select your project from the navigator in xcode and select the target for your extension > then select build phases expand the "copy bundle resources" section click the plus sign and select "add other " navigate to {your extension}/xcode project/ios (extension)/resources select the manifest json , locales , and source directories click "open" ensure "copy items if needed" and "create folder references" are checked click "finish" the files you just added will be located at the root level of your app in xcode move these three files to the {your app}/{extension name}/resources directory in the project navigator in xcode navigate back to your extension/xcode project/ios (extension) and move the info plist , extensionlaunchpad entitlements , and safariwebextensionhandler swift files to the {your app}/{extension name}/ directory inside your project in xcode uncheck the {extension name} target and click "finish" note if you do this outside of xcode, xcode may add these to your targets automatically, if this happens you’ll need to remove these from the targets select your project again and go to build phases select compile sources, click the + and select safariwebextensionhandler swift file you added earlier in the new window and click ‘add’ extension configuration settings the host application can provide configuration settings to control extension behavior and manage user attribution these values are passed from the native host app to the javascript context of the extension via safariwebextensionhandler swift 1\ get user id (required) a unique identifier generated by the host application to identify the current user if the user is not yet authenticated, return an empty string when unset, the extension will operate in a logged out state 2\ is extension enabled (required) a boolean flag that enables or disables the extension must be set to true for the extension to function if set to false , the extension will remain inactive 3\ is coupon enabled (required) a boolean flag that controls the availability of the couponator feature must be true for users to see applicable coupons on eligible checkout pages 4\ get split amount (required) a float value between 0 and 1 that determines the user's share of transaction earnings this value impacts how earning visuals are displayed examples value user earnings share 1 0 100% 0 5 50% 0 3 30% 5\ get last link timestamp (optional) a unix timestamp indicating the last time an affiliate link was presented within the host app if provided, this prevents the extension from displaying a merchant engagement alert (ema) on the next website load note configuration values can either be hard coded into safariwebextensionhandler swift or set using an app group shared between the host app and the extension 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