Build your custom data source connection screen

You want full control over your apps user experience? No problem, the SDK provides all the tools you need to create a powerful UI for data source connections.

If your UX requires a custom data source connection flow, you can easily build such screen using the Thryve SDK helper methods.

Connect/disconnect web data sources

There are two web links you need to allow your users to connect and disconnect their web data sources, respectively. To obtain these, use the getConnectDataSourceUrl and getRevokeDataSourceUrl methods of the SDK and specify the dataSourceId for the data source, you want to connect/disconnect.

The following example shows usage of getConnectDataSourceUrl and getRevokeDataSourceUrl for connection/disconnection of Fitbit:

circle-info

We recommend opening the link in an external browser and not a web view within your application. Web-views do not support social logins (e.g. Google, Facebook, or Apple sign-ins) that might be used by your end-users for certain data sources.

To make sure your user gets automatically forwarded back to your application after successfully connecting, make sure to specify a redirect URI using the redirect_uri parameter of the above SDK methods.

Connect/disconnect native data sources

Display only available native data source

Not all native data sources are available on all devices, either because they are not installed or set up by the end user. Therefore, make sure to use the isAvailable method of the SDK to only display the data source if the method returns true to avoid errors.

Connect and disconnect native data sources

Authorization of native data sources is happening on the operating system level. To make your users connect to Apple Health, Health Connect, or Samsung Health, simply call start for the corresponding source.

circle-info

Ensure you have imported and configured the needed SDK modules.

The SDK will request access to the types specified in the config object and will take care of everything, and create the connection after authorization by the end-user.

To disconnect the data source, simply call stop and the SDK will not retrieve any data and no further data will be stored until start is called again for the user.

circle-exclamation

Obtain the correct connection status

To accurately display the connection status of data sources to users, use ThryveSDK.get().getUserInformation. This method returns a list of connectedSources their IDs. Additionally, connectedAt provides the timestamp of when the user connected to each data source.

Example of button states that change depending on information returned by getUserInformation

Use the retrieved information to update the interface. Modify button actions based on this data: allow users to disconnect from connected data sources and encourage them to connect to those that are not yet linked.

Last updated