Push Inbox
Netmera Inbox 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
Integrate the NetmeraNotificationInbox, add it to your Podfile if you are using CocoaPods.
pod 'NetmeraNotificationInbox'Install the dependency and proceed with integration.
Import Statements
Before using Inbox and Notification features, make sure to add the following imports at the top of your Swift file:
import NetmeraNotification
import NetmeraNotificationInboxThis ensures that all related classes and methods are available for handling push notifications and inbox operations.
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
Create a Filter
Define the properties to filter notifications, such as status, categories, and page size.
Initialize Inbox Manager
Fetch the First Page
Request the list of matching push notifications.
Sample Code
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:
Update the status of all notifications:
Fetch More Pages
If there are more notifications than the defined page size, fetch 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.
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:
This method provides the count of notifications in the specified status.
Handling Push Objects
You can access the title, body, and subtitle of a push notification using the alert property on NetmeraInboxPush.
If the push includes a media attachment:
If you need direct access to the deep link URL:
Manage Push Notification Categories
Create message categories from Settings > Messaging & Content > Message Categories in the panel. Each category can be managed per channel (Mobile Push, SMS, Email, WhatsApp, In-App, Web) — so you can track and update a user's opt-in status either for the category as a whole or for one specific channel.
Channels are represented by the NetmeraUserCategoryPreference.Channel enum:
Getting a User's Category Preferences
Fetch the full list of category preferences (ID, name, and opt-in status):
To narrow the result down, pass categoryIds and/or channels. Both are optional and can be combined; a category that doesn't support any of the requested channels is left out of the result.
You can also filter by a single category or channel:
Each NetmeraUserCategoryPreference includes:
categoryEnabled— the overall status:trueif the category is enabled on any channel. This is always returned, regardless of channel filters.channelPreferences— a per-channel breakdown, as a list ofNetmeraUserCategoryPreference.ChannelPreference(channel,isEnabled).
Updating Category Preferences
To turn a category on or off, call setUserCategoryPreference with the category ID and the new categoryEnabled value:
To update just one channel instead of the whole category, add a channel:
Last updated
Was this helpful?