For the complete documentation index, see llms.txt. This page is also available as Markdown.

SDK Integration

Flutter Package

Example Project

For a practical example, check out the Netmera Flutter Example Project on GitHub, which shows how to integrate the Flutter SDK.

Onboarding Checklist: Flutter

Please find the Onboarding Checklist for Swift and Flutter below. Follow the titles in the checklist to ensure you have completed each essential step in your onboarding process with Netmera.

Step 1: Install Flutter

To use the Netmera Flutter SDK in your project, follow these steps:

  1. Add the following lines to your pubspec.yaml file under the dependencies section:

  1. Install the package using the command:

No additional Netmera SDK libraries are required for Android or iOS.

Step 2: Setup Android

1. Netmera Android Onboarding

In Netmera Panel:

  • Navigate to Developers > Netmera Onboarding.

  • Select Android and click Start to proceed.

2. Create a Firebase Configuration

Netmera uses Firebase Cloud Messaging (FCM) for delivering push notifications.

  1. Go to the Firebase Developers Console and create a Firebase project.

  2. Generate a new Private Key (JSON file) for your project.

  3. Upload this file in Netmera Panel > Developers > Netmera Onboarding > Android > Step 2: Create A Firebase Configuration > FCM Service Account Key.

spinner

3. Select a Target SDK

Choose the Flutter based on your application framework.

4. Integrate and Initialize Flutter SDK

5. Integrate Netmera

  1. Project’s build.gradle File

Add the following to your project-level build.gradle file:

  1. App’s build.gradle File

Add the required dependency and plugins to your app-level build.gradle file:

  1. At the top of your app’s build.gradle, include:

Important Note for Obfuscation:

If your code is obfuscated, there is no need to add any special rules for Netmera. Its functionality is unaffected by code obfuscation.

6. Initialize Netmera

  1. Create the Application Class

  • Create an application class that extends Application.

  • Replace <YOUR GCM SENDER ID>, <YOUR HMS SENDER ID>, and <YOUR NETMERA API KEY> with your actual values.

Step 3: Setup iOS

1. Create an Apple Push Notification Certificate

  1. Log in to developer.apple.com with your Apple Developer account.

  2. Generate an Apple Push Notification Certificate for your app.

  3. Export the certificate using Keychain Access on your Mac.

  4. Upload the exported certificate to the Netmera panel by navigating to Developer > Push Backends > iOS in the left menu.

Bundle IDs should match on your project, certificate and panel:

Ensure that the certificate you upload to the panel matches the bundle ID of your project. Additionally, set your project's bundle ID in the panel to ensure consistency. The bundle ID of your project, the certificate, and the one specified in the panel must all align.

Certificate types:

  • For apps downloaded from the App Store or tested via TestFlight, the certificate type should be set to "prod".

  • For apps built directly from Xcode, the certificate type must be set to "dev".

If you have problems sending push notifications when you build from Xcode, verify the certificate type on the Developer > Push Backends > iOS page in Panel.

Creating an APNS .p12 Certificate

2. Add Dependencies

Make sure Swift Package Manager integration is enabled for your Flutter project (on by default since Flutter 3.44; for earlier versions run flutter config --enable-swift-package-manager, or add the following to your app's pubspec.yaml so the setting applies to all contributors):

Then run your app as usual:

Option 2: Cocoapods

Add the following post_install block to the end of your Podfile.

Navigate to the iOS folder in your terminal and run the following command to install the required pods:

3. Add Netmera-Config.plist

Add the `Netmera-Config.plist` file to your ios/Runner directory.

If you are using Netmera on-premises, you must add your server URL as the base_url key inside sdk_params.

To obtain your SDK API Key:

  1. Go to the Netmera Panel.

  2. Navigate to Developer > API > SDK API Key.

  3. Copy your SDK API Key from this section.

Use this key to replace the YOUR-SDK-API-KEY placeholder in the sample code.

4. Configure Xcode Push Notifications Settings

  1. Open your project in Xcode.

  2. Navigate to Signing & Capabilities.

  3. Click + Capability and select Push Notifications.

  4. Click + Capability and select Background Modes then enable Background fetch and Remote notifications modes.

Step 4. Setup Dart

  1. You can set your own push callbacks in Dart side as following. These methods are optional.

2. You need a background handler to be able to listen incoming push notifications when the application is in the background or terminated state. You can add this handler as follows.

When received, an isolate is spawned (Android only, iOS does not require a separate isolate) allowing you to handle messages even when your application is not running.

Note: Since the handler runs in its own isolate outside your applications context, it is not possible to update application state or execute any UI impacting logic. You can, however, perform logic such as HTTP requests, perform IO operations etc.

For further details, refer to the documentation for more information.

Last updated

Was this helpful?