Netmera Developer Guide
Ask or search…
⌃K
Links

Custom Web View Presentation

By default, Netmera offers a visually appealing user interface (UI) when displaying web view content in push or popup notifications. It automatically handles the presentation of the web view content without requiring any additional customization.
However, if you have a standard web view presentation flow and want to use it, or want to implement your own presentation flow, you can do this by implementing the following steps:
  1. 1.
    Implement the -handleWebViewPresentation: method within your NetmeraPushDelegate object.
  2. 2.
    Within the delegate method, call the [Netmera loadWebViewContentInWebView:] method.
Warning:
Please note that the provided implementation below is a simple example and will not function independently. You must develop your own presentation flow.
Swift
Objective-C
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)
​
}
When the SDK requires presenting a web view content, such as when a popup notification is received or when a user opens a push notification containing web view content, the SDK follows this process:
  1. 1.
    The SDK checks if a NetmeraPushDelegate object has been previously set using the [Netmera setPushDelegate:] method.
  2. 2.
    If a delegate object has been set and it implements the -handleWebViewPresentation: method, the SDK calls this method.
  3. 3.
    If the delegate object does not exist or does not implement the -handleWebViewPresentation: method, the SDK automatically presents the web view content using its internal presentation flow.
It is important to ensure that you have properly set the NetmeraPushDelegate object and implemented the -handleWebViewPresentation: method in order to customize the web view presentation according to your specific requirements.
#import <Netmera/Netmera.h>
​
@interface YourClass <NetmeraPushDelegate>
@end
​
@implementation YourClass
​
- (instancetype)init {
self = [super init];
if(self) {
// Make sure you have set your object as the push delegate of Netmera SDK!
[Netmera setPushDelegate:self];
}
return;
}
​
- (void) handleWebViewPresentationForPushObject:(NetmeraPushObject *)object {
// Present your web view UI
YourWebViewController *vc = [[YourWebViewController alloc] init];
UIViewController *rootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
[rootVC presentViewController:vc animated:YES completion:nil];
​
// Load web view content inside the presented webView
[Netmera loadWebViewContentInWebView:vc.webView];
}
​
@end
​