Integrate the Ad/Tracker Blocker SDK
Integrate the Ad/Tracker Blocker SDK into your application
Prerequisites
Get Started
Integrate the JS SDK
To use the Ad/Tracker Blocker SDK in a Web or Node.js project, you must add @sudoplatform/sudo-ad-tracker-blocker
as a dependency to your project.
In order to instantiate an Ad/Tracker Blocker client, make sure you have followed instructions for Getting Started and User SDK (see Prerequisites above).
Initialize Web Assembly
The SudoAdTrackerBlockerClient
class uses a wasm module to provide high performance filtering and thus needs to load a .wasm
file at runtime. You can find this file in the following location after installing the Ad/Tracker Blocker package via npm
oryarn
:
./node_modules/@sudoplatform/ad-tracker-blocker-client/wasm/filter_engine_bg.wasm
You should instruct your bundler to add this file to your static assets, or deploy it to your CDN of choice.
Then use the initWasm
helper function to instruct the SDK how to locate this file so that it can be fetched and loaded into the Web Assembly runtime. Check out the Sample App to see an example.
Important: You should only invoke initWasm
one time in your application. It does not need to be run every time you instantiate a SudoAdTrackerBlockerClient
.
Instantiate an Ad/Tracker Blocker Client
When creating a new instance of SudoAdTrackerBlockerClient
you must provide an instance of SudoUserClient
via the sudoUserClient
property. This is used for obtaining platform authentication tokens. See the Users section for more information about SudoUserClient
.
Custom Storage Provider
By default, DefaultSudoUserClient
will not persist any cached data or user preferences. To use persistent storage, you should pass a custom storage provider that implements the StorageProvider
interface.
Check Entitlements
Import the ENTITLEMENTS_NAME
string constant that can be compared with entitlements retrieved from the Entitlements SDK getEntitlements
method.
Reset
To reset the Ad/Tracker Blocker you can use the reset
method. This will clear all cached data and reset user preferences back to defaults.
Integrate the iOS SDK
To use the Ad/Tracker Blocker SDK in an iOS project add this line to your Podfile:
Install pod dependencies by running the following command in your project directory:
This will update the local CocoaPods repository and install the latest version of the Ad/Tracker Blocker SDK.
In order to instantiate an Ad/Tracker Blocker client, make sure you have followed instructions for Getting Started and User SDK (see Prerequisites above)
To instantiate a client in your application, add the following:
You only need one client instance for a given user per device. Instantiating multiple clients with the same configuration and using them at the same time may cause unexpected runtime errors to occur.
See it in action. Be sure to take a look at the open-source iOS sample app on GitHub that our team published as a reference for integrating the Ad/Tracker Blocker SDK into your app as quickly and seamlessly as possible.
Integrate the Android SDK
To use the Ad/Tracker Blocker SDK in an Android project, add this line to the dependencies section of the app module build.gradle
and run Gradle sync.
In order to instantiate an Ad/Tracker Blocker client, make sure you have followed instructions for Getting Started and User SDK (see Prerequisites above)
To instantiate a client in your application, add the following:
You only need one client instance for a given user per device. Instantiating multiple clients with the same configuration and using them at the same time may cause unexpected runtime errors to occur.
See it in action. Be sure to take a look at the open source Android sample app on GitHub that our team published as a reference for integrating the Ad/Tracker Blocker SDK into your app as quickly and seamlessly as possible.
Last updated