Delegate Methods

Default Handling of Remote Notifications

Netmera automatically handles all UIApplicationDelegate methods related to remote notifications. You don’t need to implement these methods in your App Delegate unless your app has special use cases that require custom logic.

Custom Implementation (If Needed)

If your app needs custom handling for remote notification delegate methods, you can implement them in your UIApplicationDelegate. You can then add your specific logic inside those methods. For more details on the delegate methods related to push notifications, check the: UI Application Delegate Protocol Referencearrow-up-right.

Accessing Notification Data

To retrieve the remote notification payload, use the [Netmera recentPushObject] or Netmera.recentPushObject() method. This method returns a NetmeraPushObject instance, which contains the notification data. You can call this method within your UIApplicationDelegate methods to access the data of the received notification.

Netmera Push Delegates

In addition to the default UIApplicationDelegate handling, Netmera provides delegate APIs that allow you to listen to push notification lifecycle events and control how push content is presented.

To enable these callbacks, set the delegates in your AppDelegate:

Netmera.setPushDelegate(self)
Netmera.setPushLifecycleDelegate(self)

Push Lifecycle Events

Implement NetmeraPushLifecycleDelegate to listen to push notification lifecycle events such as receiving a push, opening it, or interacting with its actions.

extension AppDelegate: NetmeraPushLifecycleDelegate {

    func didRegisterDeviceToken(_ deviceToken: String) {
        print("Device Token: \(deviceToken)")
    }

    func didReceive(_ push: NetmeraBasePush) {
        print("Push received")
    }

    func didOpen(_ push: NetmeraBasePush) {
        print("Push opened")
    }

    func didClickActionButton(_ identifier: String, for push: NetmeraBasePush) {
        print("Action button clicked: \(identifier)")
    }

    func didClickCarouselItem(_ identifier: String?, for push: NetmeraBasePush) {
        print("Carousel item clicked: \(identifier ?? "nil")")
    }
}

These callbacks allow your application to observe push interactions and implement custom logic when needed.


Controlling Push Presentation

You can implement NetmeraPushDelegate to control how push notifications and related content are presented.


Handling WebView Presentation

If a push notification contains web content, you can control how the web view is presented.


You can also control how deep links inside push notifications are handled.

Last updated

Was this helpful?