😀Flutter SDK
Integrating FoxHat Flutter
This guide will explain how to integrate FoxHat AntiSpam into your Android application .
Features
- Emulator detection
- Rooting detection
- Detection of debugging activities
- Detection of frameworks (e.g., Frida, Xposed, Shadow)
- Secure Api
Adding FoxHat to Your Project
:::info
Download FoxHat.aar
:::
Step 1: Add the .aar File to Your Project
- Copy the downloaded
.aar
file into theandroid/app/libs/FoxHat.aar
directory of your Android project.
flutter pub add foxhat_flutter
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):
dependencies:
foxhat_flutter: ^0.0.1
Initializing FoxHat
Once installed, the SDK needs to be configured using your Publishable Key, which can be found in the Dashboard .
:::highlight orange 📌
Emulator and Root Detection enabled by default
:::
import 'package:foxhat_flutter/foxhat_flutter.dart';
final _foxhatFlutterPlugin = FoxHat();
await _foxhatFlutterPlugin.init("your_public_key");
Creating tokens
The SDK generates a token, which is a required field in the Risk and Filter APIs.
:::highlight orange 📌
It's recommended that you forward the request token as a request header to every request to your API, since then you won't need to update the app whenever you're adding new server-side calls to Castle. The default value of the header is X-FoxHat-Token, but you can specify the header name in the SDK configuration.
:::
:::info[]
Token Expiration
A new request token value should to be generated for each request to your backend. A request token will expire after 60 seconds and should only be used during a single request to your backend. It's recommended that you implement the token generation as a client-side middleware which generates a new request token with each request to your backend.
:::
const token = await _foxhatFlutterPlugin.getToken() ??
Map<String, String> requestHeaders = {};
requestHeaders["X-FoxHat-Token"] = requestToken;