com.netmera.mobile
Class NetmeraPopupService

java.lang.Object
  extended by com.netmera.mobile.NetmeraPopupService

public class NetmeraPopupService
extends java.lang.Object

This is the main class to manage pop-ups in Netmera. With the help of this class, you can start/stop listening pop-ups from Netmera to get current user pop-ups by using register(long) and unregister() methods.


Method Summary
static boolean appHasPopupToShow()
           
static boolean appHasPopupToShow(java.lang.String eventName)
           
static java.util.List<NetmeraPopup> getAllPopupsToShow()
           
static java.util.List<NetmeraPopup> getEventRelatedPopupsToShow(java.lang.String eventName)
           
static java.util.List<NetmeraPopup> getUserPopupsFromNetmera()
          Gets user&event related pop-ups from Netmera.
static void getUserPopupsFromNetmeraInBackground(NetmeraCallback<java.util.List<NetmeraPopup>> callback)
          Gets user&event related pop-ups from Netmera in background.
static boolean isRegistered()
           
static void register(long refreshPeriodInMilliseconds)
          Initializes NetmeraPopupService, registers the device to Netmera Popup on server and starts checking pop-ups from Netmera with the given period. i.e. if you set refresh period to 5000, this means service will retrieve pop-ups from Netmera in every 5 seconds.
static void unregister()
          Stops retrieving pop-ups from Netmera.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

register

public static void register(long refreshPeriodInMilliseconds)
                     throws NetmeraException
Initializes NetmeraPopupService, registers the device to Netmera Popup on server and starts checking pop-ups from Netmera with the given period. i.e. if you set refresh period to 5000, this means service will retrieve pop-ups from Netmera in every 5 seconds.

Parameters:
refreshPeriodInMilliseconds - refresh period in milli seconds
Throws:
NetmeraException - if your Netmera account type does not have Pop-up usage permission.

unregister

public static void unregister()
Stops retrieving pop-ups from Netmera. Old pop-up will be deleted. You can not use NetmeraPopupService until you call register(long). This method does not unregister the device on Netmera servers. It stops listening new popups and retrieving them.


getUserPopupsFromNetmeraInBackground

public static void getUserPopupsFromNetmeraInBackground(NetmeraCallback<java.util.List<NetmeraPopup>> callback)
Gets user&event related pop-ups from Netmera in background.

Parameters:
callback - - NetmeraCallback.onFail(NetmeraException) or NetmeraCallback.onSuccess(Object) methods called when count operation finishes.

getUserPopupsFromNetmera

public static java.util.List<NetmeraPopup> getUserPopupsFromNetmera()
                                                             throws NetmeraException
Gets user&event related pop-ups from Netmera.

Returns:
list of NetmeraPopup
Throws:
NetmeraException - if your api call limit is exceeded.

appHasPopupToShow

public static boolean appHasPopupToShow()
Returns:
true if any pop-up that user deserved to see it, else false.

appHasPopupToShow

public static boolean appHasPopupToShow(java.lang.String eventName)
Parameters:
eventName - choose from NetmeraPopup.EventType or write your custom event name.
Returns:
true if there is any pop-up related with the given event and user deserved to see them, else false.

getEventRelatedPopupsToShow

public static java.util.List<NetmeraPopup> getEventRelatedPopupsToShow(java.lang.String eventName)
Parameters:
eventName - choose from NetmeraPopup.EventType or write your custom event name.
Returns:
a list of NetmeraPopup if there is any pop-up related with the given event, else empty list.

getAllPopupsToShow

public static java.util.List<NetmeraPopup> getAllPopupsToShow()
Returns:
list of NetmeraPopup if there is any pop-up, else empty list.

isRegistered

public static boolean isRegistered()