Flutter SDK Integration
Quick Steps Guidelines
Step 1. Install Flutter
Add the lines below to your project's pubspec.yaml
file under the dependencies section.
Step 2. Android Setup
Create and configure a project on Firebase Developers Console and complete the following steps for Android Setup.
Step 3. iOS Setup
Navigate to the iOS folder in your terminal and run the commands in Step 3 to install dependencies.
Step 4. Calling Dart Methods
If you use onPrem
set baseUrl
as shown in Step 4.
Flutter SDK integration completed 👏
You may also check out the detailed document here.
Step 1. Flutter Installation
To use this package as a library in your Flutter project, follow these steps:
Add the following lines to your project's
pubspec.yaml
file under thedependencies
section.
You can install packages from the command line with Flutter:
You don't need to include extra Netmera SDK libraries for both native sides (Android & iOS).
Step 2. Android Setup
1. Select a Platform
Navigate to Netmera Panel > Developers > Netmera Onboarding and choose Android.
Click on Android > Start to proceed.
2. Create a Firebase Configuration
Netmera uses Firebase Cloud Messaging (FCM) to deliver push messages to the Android devices. Therefore, you should create and configure a project on Firebase Developers Console.
At the end of the Firebase configuration, you will have a New Private Key folder of your project. That folder must be uploaded to Developers > Netmera Onboarding > Android > Step 2: Create A Firebase Configuration > FCM Service Account Key section on Netmera Panel.
Firebase Cloud Messaging Configuration
Firebase Cloud Messaging - Generate New Private Key
Upload FCM Service Account Key on Netmera Panel
3. Select a Target SDK
Select the appropriate SDK for your application development framework from the following options: Native Android, Flutter, React Native, Unity. Note: The subsequent instructions on this page are specific to the Flutter SDK.
4. Integrate and Initialize Flutter SDK
⚠️ Warning: Do not use the API key from your test panel when setting up or deploying your production app. Each panel has its own unique API key. Even if you log in with a different account, this encrypted key stays the same. Using the wrong key can result in data being sent to the incorrect environment, causing potential issues or errors in your application.
Update Gradle Files
In your project's build.gradle file, add the following dependencies.
In your app's build gradle file, add the following dependency.
Add the following into the top of app's build.gradle file.
Create Application Class (Java):
Create an application class that extends FlutterApplication
.
Replace <YOUR GCM SENDER ID>
, <YOUR HMS SENDER ID>
, and <YOUR NETMERA API KEY>
with your actual values.
Inside Dart Class:
Inside your Dart class, add the following code to set up event handlers:
Custom Firebase Messaging Integration:
If you have a custom Firebase Messaging integration, use the following code:
Important Note:
If you're building your Flutter project with flutter run --release
and need to add the @pragma('vm:entry-point')
annotation to the _firebaseMessagingBackgroundHandler
method, you can modify the code block as follows.
Adding the @pragma('vm:entry-point')
annotation ensures that this method is correctly recognized as an entry point when building your project in release mode. This is important for background message handling in Flutter, and the annotation helps Flutter identify and execute the method as expected.
Custom Huawei Messaging Integration:
If you have a custom Huawei Messaging integration, use the following code.
Step 3. iOS Setup
To set up Netmera for iOS, follow these steps:
Navigate to the "iOS" folder in your terminal and run the following command to install dependencies:
If you're using Swift, you'll need to include the following imports in your
Runner-Bridging-Header.h
file.
If you want to enable Android-like message sending from iOS to Dart, consider configuring your
AppDelegate
class as follows.
For instance, if you trigger FNetmeraService.handleWork(ON_PUSH_RECEIVE, dict:["userInfo" : userInfo])
from AppDelegate
, the following Dart method will be triggered
For further information > You may check Step 2. Android Setup.
For instructions on using iOS 10 Media Push, please refer to the relevant documentation on page iOS Push.
Request Push Notification Authorization
In Flutter applications targeting iOS, it is necessary to request notification permissions. This can be achieved seamlessly within your Flutter codebase. Below is an example code snippet demonstrating how to request notification authorization specifically for iOS using Netmera's Flutter SDK:
Example Project: For a practical demonstration, you can refer to the sample project provided by Netmera on GitHub. The example project showcases how to integrate Netmera's Flutter SDK and includes the code snippet for requesting notification authorization on iOS:
Netmera Flutter Example Project
Step 4. Calling Dart Methods
onPrem
If you use onPrem set baseUrl,
Feel free to use the following documentation for further information.
Flutter SDK integration completed 👍
Flutter SDK integration has been successfully completed, and your devices are now ready to receive the following types of push notifications sent via the Netmera Dashboard:
Standard Push Notifications
Interactive Push Notifications (If you've configured and published them using the Dashboard)
Push Notifications with Web View Content
Push Notifications with Deeplinks (If your application supports URL Scheme-based deeplinks and you've configured the application's URL Scheme in the Dashboard.)
Last updated