Netmera Developer Guide
Netmera Docs
  • Netmera Developer Guide
  • Platforms
    • iOS
      • New iOS (Swift)
        • SDK Integration
        • Push Notifications
          • Delegate Methods
          • Widget and In-App Messages
          • Media Push
          • Carousel, Slider and Thumbnail Push
        • Deep Linking
          • Custom Deep Links
        • Sound & Vibration
        • Push Inbox
        • Events
        • Geofence & Location
        • User Attributes & Preferences
        • Advertising ID
        • Changelog
      • Former iOS (Objective-C)
        • SDK Integration
        • Push Notifications
          • Delegate Methods
          • Push Payload Receivers
          • Widget and In-App Messages
          • Customizing In-App Messages
          • Media Push
          • Carousel, Slider and Thumbnail Push
          • Custom Web View Presentation
          • Push Icon
        • Live Activities
        • Deep Linking
          • Custom Deep Links
        • Sound & Vibration
        • Push Inbox
        • Events
        • Geofence & Location
        • User Attributes & Preferences
        • Data Transfer
        • Advertising ID
        • SSL Pinning
        • Changelog
    • Android
      • SDK Integration
        • Huawei Integration
        • Huawei Message Receipt
        • Android Integration FAQs
      • Push Notifications
        • Widget and In-App Messages
        • Push Callbacks
        • Custom Web View Presentation
        • Push Icon
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
        • Background Location Permission
      • User & Attributes
      • Data Transfer
      • Advertising ID
      • App Tracking
      • SSL Pinning
      • Changelog
    • Web
      • SDK Setup
        • Self-Hosted SDK Setup
      • Mobile Web Push for iOS
      • Deep Linking
        • Custom Deep Links
      • Events
      • User & Attributes
    • React Native
      • SDK Integration
      • Push Notifications
        • Widget and In-App Messages
        • Push Callbacks
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
      • User & Attributes
      • Changelog
    • Flutter
      • SDK Integration
      • Push Notifications
        • Push Notification Permissions
        • Widget and In-App Messages
        • Flutter iOS Media Push
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
      • User & Attributes
      • SSL Pinning
      • Changelog
    • Cordova
      • SDK Integration
      • Push Notifications
      • Sound & Vibration
      • Push Inbox
      • Events
      • User & Attributes
    • Unity
      • SDK Integration
      • Sound & Vibration
      • Events
      • User & Attributes
      • Changelog
  • Integrated Modules
    • Optimove
    • Adjust
    • Mixpanel
    • IYS Integration
    • VIA Integration
      • Short URL Consent Requests
      • OTP Consent Requests
        • OTP Confirmation Completion
      • VIA Email Rejection Link Generation
      • ETK Rejection via SMS
  • API Documentation
    • REST API
      • Setup
      • Notifications
      • Events
      • User & Device Management
      • Inbox Feature
      • GDPR
      • Error Responses
  • FAQs
    • Push Notifications FAQs
Powered by GitBook
On this page
  • Push Inbox Overview
  • Filtering Notifications
  • Netmera Inbox Examples
  • Netmera Inbox Category Examples

Was this helpful?

  1. Platforms
  2. Flutter

Push Inbox

Push Inbox Overview

NetmeraInbox allows you to access and manage previously sent push notifications in an inbox-style interface. You cannot instantiate NetmeraInbox directly; instead, you must obtain an instance through the SDK and use it to interact with push notifications.

Filtering Notifications

Create a NetmeraInboxFilter instance to specify which push notifications to fetch. You can filter by:

  • Status: Read, Unread, or Deleted.

  • Categories: Filter by specific categories.

  • Expired Notifications: Include or exclude expired notifications.

  • Page Size: Number of notifications to fetch per request.

Netmera Inbox Examples

 String _currentStatus = Netmera.PUSH_OBJECT_STATUS_ALL.toString();
  String _count = "0";
  List<NetmeraPushInbox> _pushInboxList = List.empty(growable: true);

  List<DropdownMenuItem<String>> getInboxList() {
    List<DropdownMenuItem<String>> items = List.empty(growable: true);
    items.add(DropdownMenuItem(value: Netmera.PUSH_OBJECT_STATUS_ALL.toString(), child: const Text("ALL")));
    items.add(DropdownMenuItem(value: Netmera.PUSH_OBJECT_STATUS_READ.toString(), child: const Text("READ")));
    items.add(DropdownMenuItem(value: Netmera.PUSH_OBJECT_STATUS_UNREAD.toString(), child: const Text("UNREAD")));
    items.add(DropdownMenuItem(value: Netmera.PUSH_OBJECT_STATUS_DELETED.toString(), child: const Text("DELETED")));
    return items;
  }

  onInboxStatusChanged(String status) {
    setState(() {
      _currentStatus = status;
    });
  }

  String getStatusText(int status) {
    switch (status) {
      case Netmera.PUSH_OBJECT_STATUS_ALL:
        return "ALL";
      case Netmera.PUSH_OBJECT_STATUS_READ:
        return "READ";
      case Netmera.PUSH_OBJECT_STATUS_UNREAD:
        return "UNREAD";
      case Netmera.PUSH_OBJECT_STATUS_DELETED:
        return "DELETED";
    }
    return "";
  }

  fillInboxList(list) {
    setState(() {
      _pushInboxList = list;
    });
  }

  // Click Functions
  emptyAction() {}

  getInboxFilter() {
    NetmeraInboxFilter inboxFilter = NetmeraInboxFilter();
    inboxFilter.setPageSize(2);
    inboxFilter.setStatus(int.parse(_currentStatus));
    inboxFilter.setIncludeExpiredObjects(true);
    inboxFilter.setCategories(null);
    return inboxFilter;
  }

  fetchInbox() async {
    Netmera.fetchInbox(getInboxFilter()).then((list) {
      fillInboxList(list);
    }).catchError((error) {
      debugPrint(error);
    });
  }

  fetchNextPage() async {
    Netmera.fetchNextPage().then((list) {
      fillInboxList(list);
    }).catchError((error) {
      debugPrint(error);
    });
  }

  countForStatus() async {
    Netmera.countForStatus(int.parse(_currentStatus)).then((val) {
      setState(() {
        if (val != -1) {
          _count = val.toString();
        }
      });
    });
  }

  handlePushObject() async {
    if (_pushInboxList.isNotEmpty) {
      Netmera.handlePushObject(_pushInboxList[0].getPushId()!);
    }
  }

  handleInteractiveAction() async {
    if (_pushInboxList.isNotEmpty) {
      for (var element in _pushInboxList) {
        if (element.getInteractiveActions() != null && element.getInteractiveActions()!.isNotEmpty) {
          Netmera.handleInteractiveAction(element.getInteractiveActions()![0]);
          return;
        }
      }
    }
  }

  inboxUpdateStatus() {
    List<String> selectedPushList = List.empty(growable: true);
    if (_pushInboxList.length > 1) {
      selectedPushList.add(_pushInboxList[0].getPushId()!);
      selectedPushList.add(_pushInboxList[1].getPushId()!);
    }
    int status = Netmera.PUSH_OBJECT_STATUS_UNREAD;
    Netmera.inboxUpdateStatus(selectedPushList, status).then((netmeraError) {
      if (netmeraError != null) {
        debugPrint(netmeraError);
      }
    }).catchError((error) {
      debugPrint(error);
    });
  }

  updateAll() async {
    if (_pushInboxList.isNotEmpty) {
      var updateStatus = int.parse(_currentStatus);
      if (updateStatus == Netmera.PUSH_OBJECT_STATUS_ALL) {
        debugPrint("Please select different status than all!!");
        return;
      }

      Netmera.updateAll(updateStatus).then((netmeraError) {
        fetchInbox();
      }).catchError((error) {
        debugPrint(error);
      });
    }
  }

  inboxCountForStatus() async {
    NMInboxStatusCountFilter filter = NMInboxStatusCountFilter();
    filter.setStatus(int.parse(_currentStatus));
    filter.setIncludeExpired(true);
    Netmera.getInboxCountForStatus(filter).then((map) {
      String countStatusText = "ALL: " +
          map[Netmera.PUSH_OBJECT_STATUS_ALL.toString()].toString() +
          ", " +
          "READ: " +
          map[Netmera.PUSH_OBJECT_STATUS_READ.toString()].toString() +
          ", " +
          "UNREAD: " +
          map[Netmera.PUSH_OBJECT_STATUS_UNREAD.toString()].toString() +
          ", " +
          "DELETED: " +
          map[Netmera.PUSH_OBJECT_STATUS_DELETED.toString()].toString();
      setState(() {
        _count = countStatusText;
      });
    }).catchError((error) {
      debugPrint(error);
    });
  }

Netmera Inbox Category Examples

 String _currentStatus = Netmera.PUSH_OBJECT_STATUS_ALL.toString();
  List<dynamic> _categoryList = List.empty(growable: true);

  List<DropdownMenuItem<String>> getCategoryStatusList() {
    List<DropdownMenuItem<String>> items = List.empty(growable: true);
    items.add(DropdownMenuItem(value: Netmera.PUSH_OBJECT_STATUS_ALL.toString(), child: const Text("ALL")));
    items.add(DropdownMenuItem(value: Netmera.PUSH_OBJECT_STATUS_READ.toString(), child: const Text("READ")));
    items.add(DropdownMenuItem(value: Netmera.PUSH_OBJECT_STATUS_UNREAD.toString(), child: const Text("UNREAD")));
    items.add(DropdownMenuItem(value: Netmera.PUSH_OBJECT_STATUS_DELETED.toString(), child: const Text("DELETED")));
    return items;
  }

  onCategoryStatusChanged(String status) {
    setState(() {
      _currentStatus = status;
    });
  }

  String getStatusText(int status) {
    switch (status) {
      case Netmera.PUSH_OBJECT_STATUS_ALL:
        return "ALL";
      case Netmera.PUSH_OBJECT_STATUS_READ:
        return "READ";
      case Netmera.PUSH_OBJECT_STATUS_UNREAD:
        return "UNREAD";
      case Netmera.PUSH_OBJECT_STATUS_DELETED:
        return "DELETED";
    }
    return "";
  }

  // Click Functions
  emptyAction() {}

  getCategoryFilter() {
    NetmeraCategoryFilter categoryFilter = NetmeraCategoryFilter();
    categoryFilter.setPageSize(2);
    categoryFilter.setStatus(int.parse(_currentStatus));
    categoryFilter.setIncludeExpiredObjects(true);
    return categoryFilter;
  }

  fetchCategory() async {
    Netmera.fetchCategory(getCategoryFilter()).then((list) {
      fillCategoryList(list);
    }).catchError((error) {
      debugPrint(error);
    });
  }

  fetchNextCategoryPage() async {
    Netmera.fetchNextCategory().then((list) {
      fillCategoryList(list);
    }).catchError((error) {
      debugPrint(error);
    });
  }

  fillCategoryList(list) {
    setState(() {
      _categoryList = list;
    });
  }

  handleLastMessage() async {
    if (_categoryList.isNotEmpty) {
      Netmera.handleLastMessage(_categoryList[0]);
    }
  }

  updateStatusCategories() async {
    if (_categoryList.isNotEmpty) {
      List<String> selectedCategories = List.empty(growable: true);
      if (_categoryList.length == 1) {
        selectedCategories.add(_categoryList[0].getCategoryName()!);
      } else if (_categoryList.length > 1) {
        selectedCategories.add(_categoryList[0].getCategoryName()!);
        selectedCategories.add(_categoryList[1].getCategoryName()!);
      }

      Netmera.updateStatusByCategories(Netmera.PUSH_OBJECT_STATUS_READ, selectedCategories).then((netmeraError) {
        fetchCategory();
      }).catchError((error) {
        debugPrint(error);
      });
    }
  }

  getUserCategoryPreferenceList() async {
    Netmera.getUserCategoryPreferenceList().then((list) {
      fillCategoryList(list);
    }).catchError((error) {
      debugPrint(error);
    });
  }

  setUserCategoryPreference(NetmeraCategoryPreference item) async {
    Netmera.setUserCategoryPreference(item.getCategoryId()!, !item.getOptInStatus()!).then((value) {
      debugPrint("Successfully set user category preference list");
    }).catchError((error) {
      debugPrint(error);
    });
  }
PreviousSound & VibrationNextEvents

Last updated 2 months ago

Was this helpful?