Custom Web View Presentation

By default, Netmera handles the presentation of web view content in push or popup notifications automatically. However, if you want to implement your own custom presentation flow, follow these steps:

Step 1: Set the Push Delegate

Ensure your class is set as the push delegate for the Netmera SDK.

Netmera.setPushDelegate(self as! NetmeraPushDelegate)

Step 2: Implement the handleWebViewPresentation Method

In your delegate class, implement the -handleWebViewPresentation: method:

func handleWebViewPresentation(for object: NetmeraPushObject!) {
    let vc = TableViewController()
    let rootVC: UIViewController? = UIApplication.shared.keyWindow?.rootViewController
    rootVC?.present(vc, animated: true, completion: nil)
    // Load web view content inside the presented webView
    Netmera.loadWebViewContent(in: vc.webView)
}

Step 3: Presentation Flow

When a push notification with web view content is received:

  • The SDK checks if a NetmeraPushDelegate object is set.

  • If the delegate exists and implements -handleWebViewPresentation:, it will use your custom flow.

  • If no delegate or method is found, the SDK uses its default presentation flow.

Within the delegate method, call the [Netmera loadWebViewContentInWebView:] method.

The provided code is an example and requires customization for your own web view presentation flow.

import Netmera

class YourClass {
    init() {
        // Make sure you have set your object as the push delegate of Netmera SDK
        Netmera.setPushDelegate(self as! NetmeraPushDelegate)
        return
    }
}

func handleWebViewPresentation(for object: NetmeraPushObject!) {
    let vc = TableViewController()
    let rootVC: UIViewController? = UIApplication.shared.keyWindow?.rootViewController
    rootVC?.present(vc, animated: true) { _ in }
    
    // Load web view content inside the presented webView
    Netmera.loadWebViewContent(in: vc.webView)
}

Last updated

Was this helpful?