Advanced : Embed Resources Into An iOS App

The ubudu SDK allows you to execute different kind of actions. Two of them are presenting a web page to the user and presenting a Passbook coupon.

When defining such rules you typically provide a URL for a web page or a Passbook. It has the advantage of allowing you to change the content whenever you want, but forces the user to have an Internet connection when the rule triggers in order to being able to show him the content.

If your content is not meant to change often and you want to ensure that it will quickly and reliably show up, then you can decide to embed the content directly into your app bundle.

Embed the content

  • Open your project into XCode
  • Right click on your resources folder (or any folder that suits you)
  • Click 'Add files' to your Project
  • Select the file or folder you want to add
  • If you are adding a folder and want to keep the tree folder structure (you probably want to do that for a web page that depends on files like images and CSS), then check the '**Create folder references for any added folder**'

add_local_web_page.png

Set the resource URL of the rule

In the 'Rule Edit' section of the ubudu Manager, specify the URL of your web page (or Passbook coupon) by starting the URL by file://.

If you select 'Create folder references for any added folder', then you need to indicate the path to your file starting at the first folder added by reference.

Web page example: if you add a www folder that contained a www.example.com folder that itself contains the files of the web page (and so the index.html): file://www/www.example.com/index.html.

Passbook coupon example: we suppose the coupon is in a passbook folder, added to XCode by reference, so just add file://passbook/my_coupon.pkpass.

If you choose '**Create groups for any added folders**', then all the files are added to the root of the bundle, so no matters how deep inside the groups your file is, you juste need to indicate the name of you file: file://index.html, or for a Passbook coupon: file://my_coupon.pkpass