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
  • Install Netmera Notification Inbox
  • Filter and Fetch Notification
  • Update Notification Status
  • Fetch More Pages
  • Incremental Fetching
  • Checking if All Pages are Fetched
  • Push Notification Counts

Was this helpful?

  1. Platforms
  2. iOS
  3. New iOS (Swift)

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.

Install Netmera Notification Inbox

To integrate the NetmeraNotificationInbox, add it to your Podfile:

pod 'NetmeraNotificationInbox'

Install the dependency and proceed with integration.

Filter and Fetch Notification

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.

Define Inbox Manager

var inboxManager: NetmeraInboxManager?

Create a Filter

Define the properties to filter notifications, such as status, categories, and page size.

let filter = NetmeraInboxFilter(status: status,
                                pageSize: 10,
                                shouldIncludeExpiredObjects: true,
                                categories: ["category_names"]) // Optional

Initialize Inbox Manager

self.inboxManager = Netmera.inboxManager(with: filter)

Fetch the First Page

Request the list of matching push notifications.

inboxManager?.inbox(callback: { result in
	// Handle the result
})

Sample Code

// Step 1: Define the inbox manager
var inboxManager: NetmeraInboxManager?

// Step 2: Create a filter for fetching inbox notifications
let filter = NetmeraInboxFilter(
    status: status,                        // Notification status: .unread, .read, or .deleted
    pageSize: 10,                          // Number of notifications to retrieve per page
    shouldIncludeExpiredObjects: true,     // Include expired notifications
    categories: ["category_names"]         // (Optional) Filter by specific categories
)

// Step 3: Fetch Inbox
inboxManager?.inbox(callback: { result in
    switch result {
    case .success:
        // Display inbox UI with inboxManager?.objects
    case .failure(let error):
        // Handle error
    }
})

Update Notification Status

Push notifications can have three statuses:

  • Unread

  • Read

  • Deleted

You can update the status of notifications to allow users to mark messages as read, unread, or deleted.

Examples:

Update the status of a single notification:

inboxManager?.updateStatus(status, for: [object]) { result in
    // Handle status update
}

Update the status of all notifications:

inboxManager?.updateStatusForAllPushObjects(status) { result in
    // Handle status update
}

Fetch More Pages

If there are more notifications than the defined page size, fetch the next page:

inboxManager?.nextPage(callback: { result in
	// Handle the next page
})

All fetched notifications are stored in inbox.objects, and hasNextPage checks if more pages are available.

Incremental Fetching

The NetmeraInbox instance returned from -fetchInboxUsingFilter:completion: keeps the list of fetched notifications in inbox.objects. As you fetch more pages, new notifications are added to this list.

For example, if you set a page size of 10 and fetch 3 pages, inbox.objects will contain all 30 notifications from the 3 pages. This allows you to display the entire list of notifications in a table or collection view.

Error Handling

If the operation fails, the completion block will be triggered with an error describing the failure. If there are no more pages to fetch, the method will immediately call the completion block with an appropriate error.

Checking if All Pages are Fetched

You can check if there are more pages to fetch by using the hasNextPage property of the NetmeraInbox instance. If it returns false, it means all pages have been fetched.

Push Notification Counts

To get the total count of notifications based on status:

self.inboxManager?.count(for: NetmeraInboxStatus.read)

This method provides the count of notifications in the specified status.

PreviousSound & VibrationNextEvents

Last updated 1 month ago

Was this helpful?