Configure the Android side of your Flutter app for SuprSend, covering Gradle setup, FCM credentials, manifest changes, and push notification handling.
Add the following line of code inside dependencies in the pubspec.yaml file:
# pubspec.yaml
dependencies:
flutter:
sdk: flutter
suprsend_flutter_sdk: "^2.4.0"flutter pub getTroubleshooting notes
In case you face compilation errors or warnings, please perform the following troubleshooting steps:
- Ensure
mavenCentralis present underrepositoriesin the project'sbuild.gradle.- Perform a Gradle sync.
To integrate SuprSend in your Android app, you will need to initialize the SuprSend Flutter SDK in your MainApplication class.
Note:
SSApi.initshould only be called in the Application class, not inside the Activity class (MainActivity.kt). If your project does not have an Application class, create it manually and register it in theAndroidManifest.
Example: If you create a new Application class named MainApplication.kt in your source package, go to your AndroidManifest file and enter the path of the class in the <application> tag like this:
<!-- AndroidManifest.xml -->
<application
...
android:name=".MainApplication"
...
>// MainApplication.kt
package <your-package-name>
import android.app.Application
import app.suprsend.SSApi; // import sdk
class MainApplication : Application(){
override fun onCreate() {
SSApi.init(this, WORKSPACE KEY, WORKSPACE SECRET) // Important! without this, SDK will not work
SSApi.initXiaomi(this, xiaomi_app_id, xiaomi_api_key) // Optional. Add this if you want to support Xiaomi notifications framework
super.onCreate()
}
}Replace WORKSPACE KEY and WORKSPACE SECRET with values linked to your account. You'll find them on the SuprSend dashboard (Developers -> API Keys) page.
Import the SuprSend SDK in your Dart file. Go back to the flutter folder and follow the steps below:
// Main.dart
import 'package:suprsend_flutter_sdk/suprsend.dart';By default the logs of the SuprSend SDK are disabled. We recommend you enable the SDK logs by setting its value to VERBOSE. You can enable the logs just in debug mode while in development by the below condition.
suprsend.setLogLevel(level);
suprsend.setLogLevel(LogLevels.VERBOSE);
suprsend.setLogLevel(LogLevels.DEBUG);
suprsend.setLogLevel(LogLevels.INFO);
suprsend.setLogLevel(LogLevels.ERROR);
suprsend.setLogLevel(LogLevels.OFF);