Appearance
Notifications
The Flutter SDK provides comprehensive notification management functionality, allowing you to fetch notification lists, manage read/unread status, and display notifications with the built-in visual inbox.
Overview
The notifications module allows you to:
- Fetch paginated notification lists
- Mark notifications as read/unread
- Display notifications with the visual inbox
- Customize notification appearance
- Handle notification clicks and interactions
1. Notifications List
Upshot.ai provides the list of Push Notifications information received by the user for the last 90 days. This is used to create the Notifications section within the app. While setting up the push notifications, you can exclude certain notifications by adding the bkDeListing key with the end date in the Unix timestamp in the deep link key value.
How to Fetch Notifications List
dart
import 'package:upshot_flutter/upshot_flutter.dart';
import 'dart:convert';
// Fetch notifications list with pagination
import 'dart:convert';
import 'package:upshot_flutter/upshot_flutter.dart';
//fetchLimit number of notifications to fetch in one call
//daysLookback number of days (1–90) from today to include
//loadmore bool → false = fresh fetch, true = fetch next page
FlutterUpshotPlugin.getNotifications(loadmore, fetchLimit, daysLookback);
static const _channel = MethodChannel('flutter_upshot_plugin');
UpshotMethodChannel() {
_channel.setMethodCallHandler (_methodCallHandler);
}
Future <dynamic>_methodCallHandler(MethodCall call) async {
if (call.method == 'upshotGetNotifications ') {
Map data = call.arguments as Map;
}
}
Sample Notifications Response
json
{
"statusCode": 200,
"pageId": "1709177173",
"status": "success",
"data": [
{
"message": "Push Message",
"title": "Push Title",
"emsg": "",
"etitle": "",
"cid": "65e5bae2f33bdd0a840b1b15",
"read": 1,
"id": "65e5bae2f33bdd0a840b1b15",
"expiry": 1709767800000,
"msg_id": "65e5ba5b0807ed84fba786f4",
"image_url": "",
"appData": {}
}
]
}
2. Update Notification Read Status
The updateNotificationReadStatus
method allows you to update the notification read status when users interact with notifications.
dart
import 'package:upshot_flutter/upshot_flutter.dart';
FlutterUpshotPlugin.updateNotificationReadStatus(msgId);
3. Unread Notifications Count
Upshot.ai provides the count of unread notifications based on notification type. This is perfect for displaying badge counts on your notification bell icon.
Notification Types
- OnlyInAppNudges (1): Count of In-App Notifications
- OnlyPushNotifications (2): Count of Push Notifications
- AllNotifications (3): Combined count of Push & In-App notifications
How to Fetch Unread Notifications Count
dart
FlutterUpshotPlugin.getUnreadNotificationsCount(inboxType,lookbackDays);
// Get unread notification count
static const _channel = MethodChannel('flutter_upshot_plugin');
UpshotMethodChannel() {
_channel.setMethodCallHandler (_methodCallHandler);
}
Future <dynamic>_methodCallHandler(MethodCall call) async {
if (call.method == 'upshotUnreadNotificationsCount ') {
Map data = call.arguments as Map;
}
}
4. Present Notifications Screen
Upshot.ai presents a pre-built Notifications Screen on top of your application based on notification type and configuration setup. This provides a complete notifications interface without building custom UI.
Configuration Options
Option | Description |
---|---|
DisplayMsgCount | If true, shows UnreadNotifications Count / Total Notifications |
DisplayTime | If true, notification time is displayed |
EnableLoadMore | If true, enables pagination for loading more notifications |
PushLimit | Integer defining the number of notifications to fetch from server |
ShowReadNotifications | If true, shows both read and unread notifications |
Type | Notification type (1, 2, or 3) |
How to Show Notifications Screen
dart
Map configOptions = {
UpshotInboxScreenConfig.inboxType: 3,
UpshotInboxScreenConfig.showReadNotifications: true,
UpshotInboxScreenConfig.enableLoadMore: true,
UpshotInboxScreenConfig.pushFetchLimit: 100,
UpshotInboxScreenConfig.displayMessageCount: true,
UpshotInboxScreenConfig.displayTime: true,
};
FlutterUpshotPlugin.showInboxScreen(configOptions);