Flutter
How to integrate Pushwoosh SDK into your Flutter project
Plugin source Sample Plugin API Docs Geozones Plugin API Docs Message Inbox Plugin API Docs
If you encounter errors when migrating Pushwoosh Flutter Plugin to version 2.1.0 or higher, please refer to the guide on fixing known issues for solutions.
Since version 2.2.14, the package name has changed from 'pushwoosh' to 'pushwoosh_flutter'. Make sure to update your pubspec.yaml and change import lines to import 'package:pushwoosh_flutter/pushwoosh_flutter.dart'
Prerequisites
1. Create an app on Firebase Cloud Messaging Console. You may use this guide for reference (section Manually add Firebase).
2. Get iOS push certificates by following the iOS Platform Configuration guide.
3. Configure the App in Pushwoosh Control Panel. Please follow Android configuration guide for Andriod and iOS Platform Configuration guide for iOS.
Enable push notifications in your project
First, you need to add the Pushwoosh package to your project:
1. Add a dependency to your pubspec.yaml
file:
2. Install the package from the command line:
3. Import the package in your dart code:
Second, place the google-services.json
file into android/app
folder in your project directory.
google-services.json
You should've gotten the google-services.json
file while creating the app in Firebase console. If you haven't, please consult this thread (section Get a config file for your Android app).
Third, initialize the plugin:
To register for push notifications, call the following method:
To process various events, use the corresponding listeners as follows.
Push receipt:
Push open:
Deep Link open:
All done!
Plugin API
To find more details on using the plugin, please see Plugin API Docs.
Using ProGuard
Note that the flutter build apk
command obfuscates your code by default.
Thus, you may get this exception:
There are two solutions in this case:
Use the
flutter build apk --no-shrink
command to compile your code without obfuscation.Or you can manually enable ProGuard and add the necessary rules.
To enable ProGuard for your project, add the following strings to your build.gradle file:
Then, add the following rules to the android/app/proguard-rules.pro
Share your feedback with us
Your feedback helps us create a better experience, so we would love to hear from you if you have any issues during the SDK integration process. If you face any difficulties, please do not hesitate to share your thoughts with us via this form.
Last updated