# App-to-app integration

Next to integrating the FibriCheck technology into your application, it's also possible to implement an app-to-app integration. In this scenario, your users will use the FibriCheck application to perform measurements.&#x20;

An app-to-app integration has two components:

* The ability to redirect the user from your application to the FibriCheck mobile application&#x20;
* The ability to access and visualize the measurement results in your application

<figure><img src="https://550842036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1VHmKXYQVUzvBkU504K0%2Fuploads%2Fl4omLBS9K0C3EFOOnA3F%2Fdocs.fibricheck.com%20-%20app-to-app%20integration.png?alt=media&#x26;token=646db536-0ddd-466c-9947-cfb97a2b2225" alt=""><figcaption></figcaption></figure>

The following videos show how this works in practice:&#x20;

**Example 1: Clicking the deep link for the first time**

When a user clicks the deeplink without the FibriCheck app installed, they will be directed to the app store to download it. After installation, the deeplink information will be transferred to the FibriCheck application, ensuring a convenient onboarding.

{% embed url="<https://drive.google.com/file/d/1RRCjveVCabnQ6Nz69-CFsddFCWYhFcE8/view?usp=drive_link>" %}

**Example 2: Clicking the deep link after the first time, when installation has completed**&#x20;

Once the user has installed the FibriCheck mobile app and created an account, a deep link can instantly direct them from your application to the measurement feature within FibriCheck.

{% embed url="<https://drive.google.com/file/d/1QAH6QKsUJ2SSGmO-47_WFfJ8lvqBC_2A/view?usp=drive_link>" %}

## High-level app-to-app sequence diagram

The following sequence diagram shows an overview of the different steps involved in onboarding a (new) patient to FibriCheck through an app-2-app integration with a partner platform.&#x20;

<br>

<figure><img src="https://550842036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1VHmKXYQVUzvBkU504K0%2Fuploads%2FPQ97vh01tISduNFNW4AC%2Fimage.png?alt=media&#x26;token=82e4ce79-4b8c-4e33-b588-af5392e47c16" alt=""><figcaption></figcaption></figure>

## Redirect the user to the FibriCheck mobile application

To redirect the user from your application to FibriCheck, we provide [deep links](https://en.wikipedia.org/wiki/Mobile_deep_linking). Deep links can be used in another app, on the web, in an email, or sms. When users click on the link or button, they are redirected to the FibriCheck app. Using this method, integrating FibriCheck in your application only requires adding a button in your app that contains the deep link.

If the user has not installed the FibriCheck app yet, the link will be a [deferred deep link](https://en.wikipedia.org/wiki/Mobile_deep_linking#Deferred_deep_linking). The user is then first redirected to the App or Play Store to download the app. After the app is installed, the user will be redirected to the deep link as if the app was already installed.&#x20;

### Deep Link URL&#x20;

A deep link URL with different query parameters is available which allows you to:

* Provide user information to facilitate onboarding
* Redirect the user to different parts of the FibriCheck application, e.g. directly to the measurement functionality of the mobile application&#x20;
* Provide activation information so that the user can immediately start measuring their heart rhythm

The following example shows combines all possibilities in one URL:

```
https://fibricheck.app.link?
	fc_hash={{prescription hash}}&
	fc_data_extra_{{partner_prefix}}_patient_id={{partner patient id}}&
	fc_data_extra_{{partner_prefix}}_{{other_param}}={{partner other parameters}}&
	fc_reg_first_name={{patient's first name}}&
	fc_reg_last_name{{patient's last name}}=&
	fc_reg_email={{patient's last name}}&
	fc_reg_language={{language}}&
	fc_reg_country={country}}&
	fc_reg_gender={{gender}}
```

More specific information on the different parameters are provided in the sections below.

<details>

<summary>Prefilled user registration</summary>

Deeplink URL:&#x20;

`https://fibricheck.app.link/?fc_reg_email=demo1%2B4%40fibricheck.com`

This deeplink allows you to pre-fill information in the FibriCheck app to register a new user&#x20;

The following query parameters map directly onto the [registration parameters](https://docs.fibricheck.com/introduction/registration#register-a-new-user):

* `fc_reg_first_name`&#x20;
* `fc_reg_last_name`
* `fc_reg_email`
* `fc_reg_language`
* `fc_reg_country`
* `fc_reg_gender`

If some query parameter values are not provided, the user will be able to provide them in the registration form within the FibriCheck application.

Additionally, custom properties can be provided that will be stored in the `custom_fields` property of the [user's profile](https://docs.fibricheck.com/introduction/profile) using the dynamic query parameter `fc_data_{fieldName}`.

The query parameters from the "activate a prescription" deeplink (`fc_hash`) can be added here as well. Then the user will be able to directly perform measurements after registering.

</details>

<details>

<summary>Show an overview of measurements to the user</summary>

Deeplink URL: \
`https://fibricheck.app.link/?screen=measurements_overview`

<img src="https://550842036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1VHmKXYQVUzvBkU504K0%2Fuploads%2FFJbja1oufYZFpsl0jKsP%2Fimage.png?alt=media&#x26;token=43de802a-d7b0-4429-891e-fc2f7d7281b6" alt="" data-size="original">

</details>

<details>

<summary>Show a specific measurement result to the user</summary>

Deeplink URL: \
`https://fibricheck.app.link/?screen=measurement&measurementId=xxx`

![](https://550842036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1VHmKXYQVUzvBkU504K0%2Fuploads%2FfIGrzzx91qc2UP8ug2Je%2Fimage.png?alt=media\&token=620ba933-b89a-4438-8f60-f0c8b3f92d68)

</details>

<details>

<summary>Start a measurement with instructions on how to measure</summary>

Deeplink URL: \
`https://fibricheck.app.link/?screen=measurement_instructions`

![](https://550842036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1VHmKXYQVUzvBkU504K0%2Fuploads%2FUvlvKSF0OsI3ougLniTe%2Fimage.png?alt=media\&token=b6bbd6be-f212-40c7-bc9d-513e9b8c9a3b)

</details>

<details>

<summary>Start a measurement</summary>

Deeplink URL: \
`https://fibricheck.app.link/?screen=start_measurement`

![](https://550842036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1VHmKXYQVUzvBkU504K0%2Fuploads%2FYGHzxARQMLW2UT7zUonM%2Fimage.png?alt=media\&token=21185cbe-8124-4b56-974d-fb6f52214482)

</details>

<details>

<summary>Activate a prescription</summary>

Deeplink URL: `https://fibricheck.app.link/?fc_hash={{hash}}`

The provided prescription hash will be activated upon app launch, so the user can immediately start measuring.

</details>

<details>

<summary>Provide additional information</summary>

The following query parameters allow partners to store specific information related to the integration:

* `fc_data_extra_{{partner_prefix}}_patient_id={{partner patient id}}` \
  Should contain the unique identifier of the patient in the partner system. If you integrate using webhooks, this value will be provided in each webhook request that is performed to facilitate mapping users in FibriCheck with users in the partner system.
* `fc_data_extra_{{partner_prefix}}_{{other_param}}={{partner other parameters}}` \
  Can be used to store other relevant information linked to the patient in the patient's profile within FibriCheck.

The `{{partner_prefix}}` is a key that will be given to you to scope all information related to the integration.

</details>

{% hint style="warning" %}
**Note that all query parameters for the deep links must be URL encoded.**
{% endhint %}

{% hint style="info" %}
The user has to click on the deep link to be redirected to the FibriCheck app.

The deep link functionality does not work when the link is copied in the address bar of a web browser.
{% endhint %}

### Environments

If you're testing your integration, you'll be using the development environment, which has a different base URL.

<table data-header-hidden><thead><tr><th width="346"></th><th width="428.3333333333333"></th></tr></thead><tbody><tr><td><span data-gb-custom-inline data-tag="emoji" data-code="1f1ea-1f1fa">🇪🇺</span> Non-US - Development App</td><td><a href="https://fibricheck.test-app.link">https://fibricheck.test-app.link</a></td></tr><tr><td><span data-gb-custom-inline data-tag="emoji" data-code="1f1fa-1f1f8">🇺🇸</span> United States - Development App</td><td><a href="https://fibricheck-us.test-app.link">https://fibricheck-us.test-app.link</a> </td></tr><tr><td><span data-gb-custom-inline data-tag="emoji" data-code="1f1ea-1f1fa">🇪🇺</span> Non-US // Production App</td><td><a href="https://fibricheck.app.link">https://fibricheck.app.link</a></td></tr><tr><td><span data-gb-custom-inline data-tag="emoji" data-code="1f1fa-1f1f8">🇺🇸</span> US // Production App</td><td><a href="https://fibricheck-us.app.link">https://fibricheck-us.app.link</a></td></tr></tbody></table>

## Access measurement data in your application

When a user performs a measurement in the FibriCheck application, the measurements, analysis, and diagnosis are performed and stored in the FibriCheck cloud.

There are two ways to get the measurement data into your application.&#x20;

### Submit your application as a connected app in FibriCheck

Connected apps are applications that FibriCheck integrates with. For connected apps, FibriCheck will push the measurements and reports into the connected app.

To support this, your application needs to provide an API that FibriCheck can access using an OAuth2.0 authorization flow.&#x20;

The user will have to take the following steps to connect your application:

1. The user logs in to the FibriCheck application
2. In the "Connected apps" screen, the user selects your application
3. The user is redirected to your application's login screen
4. After successful authentication, the user is redirected to FibriCheck
5. FibriCheck receives access tokens that are used to push the measurement data into your application&#x20;

Because the user signs in, there is a hard link between the user's account in your application and the user's FibriCheck account, thereby making sure that measurements are linked to the correct account.

{% hint style="info" %}
This method requires help from the FibriCheck technical team to implement. Reach out to <integrations@fibricheck.com> to discuss your specific use case.
{% endhint %}

### Access the measurements using the REST API

The FibriCheck cloud offers a REST API and associated Cloud SDK to fetch measurements. You can use this API to fetch the measurements into your system.&#x20;

See [this link](https://docs.fibricheck.com/introduction/measurements#fetch-a-measurement) for more information.&#x20;

{% hint style="warning" %}
When using this method, you have to be very careful that you match the measurements with the correct user.&#x20;
{% endhint %}
