Netmera Popup

Pop-ups are very helpful in boosting in-app communication with users. They are shown according to user actions such as app opens, specific page views, or other valuable custom actions that you have decided.

Best thing about Netmera pop-up service is that you do not need to change anything in your app to change the message that is displayed. Each time the user opens the app; Netmera SDK will download the latest pop-up contents and display the current message.

Each pop-up notification is related to an event which will trigger pop-up when it is fired by the application. For example, if user opens the app and if there is any pop-up triggered by this open event, this pop-up will be available to be presented to user. However, Netmera does not show pop-ups automatically after these events. Instead, it stores currently available pop-ups in a structured way, so that you can achieve and present them to user whenever and wherever you want.

Step 1: Triggering Popups

There are two techniques that you can use in iOS SDK to get pop-ups triggered by their relevant event.

First one is to call addObserver:forEventKey:usingBlock: and removeObserver:forEventKey: methods.

The logic of these methods are similar to the ones featuring in “NSNotificationCenter” class. Whatever events you want to listen for popups, you should give the name of the event as parameter. (For Open app events, you should use ‘NMAppOpenEvent’ constant.) If you give this parameter nil, you will be informed whenever an event fires.

You should also provide an observer object, usually a UIViewController object, for tracking the event. This object is important when you want to remove the relevant observer to track the event. When an event fires, if you listen to it, your block is executed with the triggered popups binded to it. You can see it the argument signature of the block parameter. (void(^NMPopupTriggerResult)(NSMutableArray *triggeredPopups))

To add an observer for one of your custom events in a controller, you should use the following code.

[NMPopupManager addObserver:self forEventKey:YOUR_EVENT_KEY usingBlock:^(NSMutableArray *triggeredPopups) {
     // You can continue to presentation procedure or anything else regarding popup object.

To add an observer for popups that are related to all different types of events, use the following:

[NMPopupManager addObserverForAllEvents:self usingBlock:^(NSMutableArray *triggeredPopups) {
     // You can continue to presentation procedure or anything else regarding popup object.

To remove the registered observer, you should use the following code. It is recommended that if you add a controller object as an observer, you should at least call this method in ‘dealloc’ implementation.

[NMPopupManager removeObserver:self forEventKey:YOUR_EVENT_KEY];

To remove observer for all events, use the following:

[NMPopupManager removeObserverForAllEvents:self];


The second technique is to call the methods named getTriggeredPopups: and getTriggeredPopupsWithEventKey:. They return an NSArray object that contains available NMPopupObject objects. From the list, you should choose which pop up you want to show. You can define more than one pop up for each event and that is why these methods return list instead of one NMPopup object.

By using these methods, you can gather triggered pop-ups and present it to user whenever you want.

In case you want to get pop-ups which have been triggered by a specific event, you should use following code.

NSArray *popupList = [NMPopupManager getTriggeredPopupsWithEventKey:YOUR_EVENT_KEY];
NMPopupObject *popup = [popupList objectAtIndex:INDEX];
// After that, you can continue to presentation procedure

Whereas, if you wish to get all triggered pop-ups without regarding by which event it is triggered, you can use getTriggeredPopups method.

Step 2: Displaying Popups

Presenting pop-ups onto screen is very simple. After you get the NMPopupObject object you want to show using one of the get methods, you just call one of the following to present pop-up on screen.

[NMPopupManager presentPopup:POPUP_OBJECT];

This method presents given pop-up on top of the currently visible controller. Pop-up is shown as a modal controller – on full screen – using a fancy poppy animation.

[NMPopupManager presentPopup:POPUP_OBJECT fromController:PARENT_CONTROLLER];

This method presents given pop-up on top of the given view controller.

Additionally, if you need you show your popup in another custom way, you could add a UIWebView in your view hierarchy, and then you can load your pop-up to this webview using following line of code:

NMPopupObject *popup = [[NMPopupManager getTriggeredPopups] objectAtIndex:INDEX];
[popup presentInWebView:WEBVIEW_OBJECT];

March 31, 2015 / parag

Recent Blog Posts
Retargeting: how to make the best of your past mobile campaigns
User Profiles Targeting: personalization made easy