For the complete documentation index, see llms.txt. This page is also available as Markdown.

Push Notification Permission

This page explains how to request iOS push notification permission, enable the required Xcode capability, and control Netmera push delivery state in your app.

System Permissions

Step 1: Add the notification dependency

Choose the dependency manager you use in your project.

Swift Package Manager

In Xcode, go to File → Add Package Dependencies and enter the Netmera iOS SDK repository URL. Then select NetmeraNotification from the available package products and add it to your app target.

CocoaPods

Add the following line to your app target in the Podfile.

pod "NetmeraNotification"

Then run:

pod install

Step 2: Request notification permission

To send push notifications, request authorization from the user.

Netmera.requestPushNotificationAuthorization(for: [.alert, .badge, .sound])

Mandatory for Interactive Push Buttons

If your app uses interactive push notifications, calling the authorization method is required. Without it, the SDK cannot register or handle notification actions correctly.

Handling the authorization callback

You can use a completion handler to check whether the user granted permission and handle errors.

Checking System Notification Permission

Use checkNotificationPermission to query the iOS system-level authorization status.

NetmeraPushPermissionType returns one of the following values:

Value
Meaning

.granted

User has granted notification permission

.denied

User has denied the permission prompt

.blocked

Notifications are blocked at the system level

.notDetermined

Authorization has not been requested yet

Step 3: Enable Push Notifications in Xcode

Enable the push capability in your Xcode project.

  • Open your Xcode project.

  • Go to Signing & Capabilities.

  • Under Capability, select Push Notifications.

Step 4: Implement UNUserNotificationCenterDelegate

In your AppDelegate, set the notification center delegate in didFinishLaunchingWithOptions.

Then add the delegate methods that handle foreground presentation and user interaction.

Push Opt-In Status

Netmera iOS SDK also lets you control whether the device can receive Netmera push notifications.

checkNotificationPermission and isReceivingPushNotificationsEnabled check different things:

  • checkNotificationPermission checks the iOS system permission.

  • isReceivingPushNotificationsEnabled checks the Netmera opt-in state.

  • Netmera.setReceivingPushNotificationsEnabled(true) enables Netmera push delivery.

  • Netmera.setReceivingPushNotificationsEnabled(false) disables Netmera push delivery.

Checking push notification status

Use the following method to check whether the device can currently receive Netmera push notifications.

The method returns a boolean value.

  • true means push notifications are enabled for the device in Netmera.

  • false means push notifications are blocked or disabled.

  • You can reflect this value directly in the UI, such as a UISwitch.

Last updated

Was this helpful?