suprsend_flutter_sdk 3.0.0 copy "suprsend_flutter_sdk: ^3.0.0" to clipboard
suprsend_flutter_sdk: ^3.0.0 copied to clipboard

SuprSend Flutter SDK — user identification, event tracking, user channels and push notifications, wrapping the native SuprSend Android and iOS SDKs.

SuprSend Flutter SDK #

This SDK is used to integrate SuprSend features like Mobile Push, Preferences and InApp feed in to your Flutter application.

Installation #

Add the SDK to your pubspec.yaml:

dependencies:
  suprsend_flutter_sdk: ^3.0.0
flutter pub get

Requirements: iOS 15.0+, Android minSdk 19.

For iOS, set the deployment target in ios/Podfile, then run pod install:

platform :ios, '15.0'

Integration Steps #

Step 1: Create Client Instance #

Initialize the SuprSend client inside main. All the methods of SuprSend SDK can be accessed only after creating instance.

import 'package:suprsend_flutter_sdk/suprsend_flutter_sdk.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  SuprSend('YOUR_PUBLIC_KEY');

  runApp(const MyApp());
}
Parameter Description
publicKey* Required. Your workspace public key from the SuprSend dashboard (ApiKeys → Public Keys).
host Optional. Custom SuprSend API host; only needed for self-hosted or region-specific setups.

Step 2: Authenticate User #

Authenticate user so that all the actions performed after authenticating will be w.r.t that user. This is mandatory step and need to be called before using any other method. This is usually performed after successful login and on reload of page to re-authenticate user (can be changed based on your requirement).

await SuprSend.identify(
  'user-distinct-id',
  userToken: jwt, // only needed in production environments for security
  refreshUserToken: (oldUserToken, tokenPayload) async {
    return await myBackend.fetchSuprSendToken();
  },
);
Properties Description
distinctId* Unique identifier to identify a user across platform.
userToken Mandatory when enhanced security mode is on. This is ES256 JWT token generated in your server-side. Refer docs to create userToken.
refreshUserToken This function is called by SDK internally to get new userToken when existing user token is expired. The returned string is used as the new userToken.

Step 3: Reset User #

This will remove user data from SuprSend instance similar to logout action.

await SuprSend.reset();

Push Notifications #

Push is configured natively on each platform. Follow the platform-specific guide:

Logging #

Add below code in main below the SuprSend instance creation to see logs for debugging.

await SuprSend.enableLogging();

API Response #

All SuprSend SDK methods returns SSResponse. Use it to check whether a call succeeded and to read error details when it didn't.

final response = await SuprSend.user.addEmail('user@example.com');
if (response.isSuccess) {
  // handle success
} else {
  print('${response.errorType}: ${response.errorMessage}');
}
Property Description
status "success" or "error".
isSuccess true when the call succeeded (convenience getter over status).
statusCode HTTP status code, when available.
errorType Error category, e.g. VALIDATION_ERROR, NETWORK_ERROR.
errorMessage Human-readable error message.
2
likes
135
points
273
downloads

Documentation

Documentation
API reference

Publisher

verified publishersuprsend.com

Weekly Downloads

SuprSend Flutter SDK — user identification, event tracking, user channels and push notifications, wrapping the native SuprSend Android and iOS SDKs.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on suprsend_flutter_sdk

Packages that implement suprsend_flutter_sdk