Skip to main content
The Notifly Flutter plugin connects your Flutter app to Notifly. The SDK supports the following features:
  • Register devices with Notifly to receive push notifications and display in-app popups. (In-app popups appear only while the app is in the foreground.)
  • Send event and user data to Notifly for campaign targeting and analysis.
  • Log user behavior as events and measure campaign performance.
In-app popups on Android require Android 11 (API level 30) or later.

Prerequisites

  1. Connect your Firebase project.
    The Notifly iOS SDK uses Firebase Cloud Messaging to send push notifications.
Connect Firebase
  1. Register your APNs credentials for iOS.
Register APNs credentials
  • For iOS builds, open Runner.xcworkspace in Xcode.

1. Set up the plugin

Install the plugin

The flutter pub add command adds the dependency to pubspec.yaml. The badge shows the latest published version. Pub

Configure iOS

1. Configure capabilities

  1. Open Runner.xcworkspace in Xcode. Use the workspace rather than .xcodeproj to build with the Notifly SDK.
  2. Set the target’s minimum iOS version to 15.0 or later. Set the same minimum version in your Podfile.
  3. Enable Push Notifications and Background Modes, including Remote notifications and Background fetch. Add Capabilities Add Capabilities

2. Configure AppDelegate.swift

  1. Locate the file.
The Swift AppDelegate file is at the following path:
  1. Import notifly_sdk.
  1. Update AppDelegate.swift.
Override the relevant FlutterAppDelegate methods to add the Notifly integration code.
AppDelegate.swift
Requires notifly-sdk version 1.3.0 or later.
Configure a Notification Service Extension to use rich push notifications. Follow the Push Extension guide.

Supported features

  1. Attach images and videos to push notifications.
  2. Track push notification delivery to analyze campaign performance in more detail.
The SDK works without a Notification Service Extension, but rich push notifications and delivery tracking are unavailable.

Initialize the SDK

Add the Notifly plugin initialization code to your app’s entry point, such as main.dart. You can load environment variables with a package such as dotenv.
main.dart
Find NOTIFLY_PROJECT_ID and NOTIFLY_USERNAME on the settings page. password is a placeholder for backward compatibility. Pass the same nonempty value as username. Do not pass a real password or API Secret Key.

2. Register user information

Notifly uses user identifiers (userId) and user properties (params) to personalize marketing campaigns.
Registered user information supports segmentation and targeting for channels such as push notifications, email, and Kakao AlimTalk.

1. Set the user ID (NotiflyPlugin.setUserId())

Map userId to the identifier of the signed-in user in your app.
Notifly uses this value to track user events and personalize campaigns.

Parameters

String
The signed-in user’s ID. Pass null on sign-out to clear the association.

Clear the user ID

On sign-out, call setUserId(null) to clear the association between the current device and the user. To retain the same user data, manage it separately on your server or in your app.
setUserId

2. Set user properties

setUserProperties registers properties for the user.
These properties support segment targeting, message personalization, and delivery channel selection.
Before you send sensitive user propertiesBefore you send a custom user property that needs protection, such as a name or address, register it with the exact key you plan to send and enable encryption under User Management > User List > Property management in the console.See Manage user properties for setup instructions and limitations.
Map<String, Object>
required
Key-value pairs of user properties. Supports predefined keys such as $email, $phone_number, and $line_user_id.
  • $email: Email address for email campaigns.
  • $phone_number: Phone number for SMS and Kakao campaigns.
  • $line_user_id: LINE user ID for LINE message campaigns.
  • Custom fields: Define your own fields, such as "plan", "tier", and "country".
setUserProperties

3. Log events

Record user behavior to use in campaign triggers, segment conditions, and performance analysis.
For example, collect button clicks, page visits, and completed purchases as events.

Parameters

String
required
Event name, such as "click_button" or "purchase_completed".
Map<String, Object>
Additional event parameters, such as "plan": "premium" or "duration": 120.
List<String>
List of event parameter keys to use for segmentation. Supports at most one key.
Use segmentationEventParamKeys to make an event parameter (eventParams) available for targeting. You can specify at most one key.
trackEvent

4. Get the internal user ID

getNotiflyUserId() returns the unique user ID that Notifly manages internally.
This ID is separate from the user ID set with setUserId(). Most integrations do not need it.
Use it when an external CRM or third-party integration requires Notifly’s internal user ID.
This method is not supported on the web.

5. Configure web push notifications (web only)

Complete this section only if you use web push notifications in Flutter Web.
For iOS and Android apps, skip this section.

1. Register the service worker

Register a service worker to receive web push notifications.
  1. Create notifly-service-worker.js in your Flutter project’s web/ directory.
  2. Add the following code:
web/notifly-service-worker.js
This file receives and displays push notifications while the browser runs in the background.

2. Request web push permission

Web push notifications require the user’s explicit permission in the browser.
  1. Automatic permission request (default)
  • In the Notifly console, go to Settings > SDK Settings > Website Settings. Under Permission Prompt Settings, turn on Auto Display.
  • When enabled, the permission prompt appears automatically when a user visits your website.
  1. Manual permission request (optional)
Web push permission settings
  • Turn off the automatic display option in the console to control when your app requests permission.
  • Call the following method:
requestPermission() works only when automatic permission requests are turned off in the console.

3. Permission behavior

  1. If the user has not chosen a permission setting, the prompt appears.
Browser notification permission prompt
  1. If the user has already granted permission, the prompt does not appear again.
  2. If the user has denied permission, browser policy prevents the prompt from appearing again.

6. Test the integration

After you install the SDK, follow Test your integration to verify event collection and push notification delivery.

7. Advanced integration

Push notification icons

Request push notification permission

Push notification click events

FAQ

The Notifly Android SDK can work alongside Firebase Cloud Messaging that your app already uses.