com.netmera.mobile
Class NetmeraPushService

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

public class NetmeraPushService
extends java.lang.Object

This is the main class to manage push notifications in Netmera. With the help of this class, you can register/unregister devices into different groups to get notification.


Nested Class Summary
static class NetmeraPushService.NotificationStyleActionController
          This class is used to set actions for new notification styles of Android.
 
Constructor Summary
NetmeraPushService()
           
 
Method Summary
static void disablePushInbox()
          Disables push inbox.
static void enablePushInbox()
          Enables push inbox.
static void getDeviceDetailInBackground(android.content.Context context, NetmeraCallback<NetmeraDeviceDetail> callback)
          Retrieves the detailed information of a registered device in the background thread.
static void getDeviceGroupsInBackground(int max, int page, NetmeraCallback<java.util.List<java.lang.String>> callback)
          Deprecated. 
static void getDeviceGroupsInBackground(NetmeraCallback<java.util.List<java.lang.String>> callback)
          Deprecated. 
static java.lang.String getPushMessage()
          Retrieves the latest arrived push notification message
static java.lang.String getRegistrationId(android.content.Context context)
          Retrieves the registration id of the registered device.It returns empty string if not registered.
static void getTagsInBackground(int max, int page, NetmeraCallback<java.util.List<java.lang.String>> callback)
          Retrieves the specified tags list of all registered devices in the background thread.
static void getTagsInBackground(NetmeraCallback<java.util.List<java.lang.String>> callback)
          Retrieves the first 10 tags of all registered devices in the background thread.
static boolean handleRichPush(android.app.Activity pushActivity)
          If the coming push notification is rich, the method creates a web view and loads the content of the notification.
static boolean handleRichPush(android.app.Activity pushActivity, java.util.List<NetmeraJavascriptInterface> javascriptInterfaces)
          If the coming push notification is rich, the method creates a web view, adds given list of javascriptInterfaces to the web view and loads the content of the notification.
static boolean handleRichPush(android.app.Activity pushActivity, NetmeraJavascriptInterface javascriptInterface)
          If the coming push notification is rich, the method creates a web view, adds given javascriptInterface to the web view and loads the content of the notification.
static void handleRichPushWithId(android.webkit.WebView richPushWebView, java.lang.String messageId)
          Loads rich push content to the given Webview
static boolean isRegistered(android.content.Context context)
          Checks whether device is registered or not.
static boolean isRichPush()
          Gets the boolean value according to push notification type
static void register(android.content.Context context, java.lang.String senderId, java.lang.Class<? extends android.app.Activity> pushActivityClass)
          Registers device.
static void register(NetmeraDeviceDetail deviceDetail)
          Registers device with the given device detail information
static void unregister(android.content.Context context)
          Unregisters device.
static void unregister(NetmeraDeviceDetail pushDeviceDetail)
          Unregisters device completely.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetmeraPushService

public NetmeraPushService()
Method Detail

register

public static void register(android.content.Context context,
                            java.lang.String senderId,
                            java.lang.Class<? extends android.app.Activity> pushActivityClass)
                     throws NetmeraException
Registers device.

Parameters:
context - application's context
senderId - Google Project Number of your application on Google Cloud Services.
pushActivityClass - opening activityClass when the push notification is send. This activity should extend NetmeraActivity class instead Activity if possible.
Throws:
NetmeraException

register

public static void register(NetmeraDeviceDetail deviceDetail)
                     throws NetmeraException
Registers device with the given device detail information

Parameters:
deviceDetail - NetmeraDeviceDetail object
Throws:
NetmeraException

isRegistered

public static boolean isRegistered(android.content.Context context)
Checks whether device is registered or not.

Parameters:
context - application's context
Returns:
true if registered, false otherwise

getRegistrationId

public static java.lang.String getRegistrationId(android.content.Context context)
Retrieves the registration id of the registered device.It returns empty string if not registered.

Parameters:
context - application's context
Returns:
registration id

getDeviceGroupsInBackground

@Deprecated
public static void getDeviceGroupsInBackground(NetmeraCallback<java.util.List<java.lang.String>> callback)
                                        throws NetmeraException
Deprecated. 

Retrieves the first 10 tags of all registered devices in the background thread.

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

getTagsInBackground

public static void getTagsInBackground(NetmeraCallback<java.util.List<java.lang.String>> callback)
                                throws NetmeraException
Retrieves the first 10 tags of all registered devices in the background thread.

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

getDeviceGroupsInBackground

@Deprecated
public static void getDeviceGroupsInBackground(int max,
                                                          int page,
                                                          NetmeraCallback<java.util.List<java.lang.String>> callback)
                                        throws NetmeraException
Deprecated. 

Retrieves the specified tags list of all registered devices in the background thread.

Parameters:
max - The total number of results to return. If it is less than or equal to 0 then it is set to 10.
page - The index of the page to retrieve data. If it is less than 0 then it is set to 0.
callback - NetmeraCallback.onSuccess(Object) or NetmeraCallback.onFail(NetmeraException) methods called when operation finishes.
Throws:
NetmeraException

getTagsInBackground

public static void getTagsInBackground(int max,
                                       int page,
                                       NetmeraCallback<java.util.List<java.lang.String>> callback)
                                throws NetmeraException
Retrieves the specified tags list of all registered devices in the background thread.

Parameters:
max - The total number of results to return. If it is less than or equal to 0 then it is set to 10.
page - The index of the page to retrieve data. If it is less than 0 then it is set to 0.
callback - NetmeraCallback.onSuccess(Object) or NetmeraCallback.onFail(NetmeraException) methods called when operation finishes.
Throws:
NetmeraException

getDeviceDetailInBackground

public static void getDeviceDetailInBackground(android.content.Context context,
                                               NetmeraCallback<NetmeraDeviceDetail> callback)
                                        throws NetmeraException
Retrieves the detailed information of a registered device in the background thread.

Parameters:
context - application's context
callback - NetmeraCallback.onSuccess(Object) or NetmeraCallback.onFail(NetmeraException) methods called when create operation finishes.
Throws:
NetmeraException

unregister

public static void unregister(android.content.Context context)
Unregisters device.

Parameters:
context - application's context

unregister

public static void unregister(NetmeraDeviceDetail pushDeviceDetail)
Unregisters device completely. If NetmeraDeviceDetail tags are set; unregisters device from tags.

Parameters:
pushDeviceDetail - NetmeraDeviceDetail object

handleRichPushWithId

public static void handleRichPushWithId(android.webkit.WebView richPushWebView,
                                        java.lang.String messageId)
                                 throws NetmeraException
Loads rich push content to the given Webview

Parameters:
richPushWebView - WebView of registered activity class to the push notification
messageId - Id of the rich push content obtained from the basic push notification
Throws:
NetmeraException - Throws exception if it cannot access server

isRichPush

public static boolean isRichPush()
Gets the boolean value according to push notification type

Returns:
Returns true if the type of the push notification is rich, false otherwise

getPushMessage

public static java.lang.String getPushMessage()
Retrieves the latest arrived push notification message

Returns:
pushMessage Message of the latest push notification

handleRichPush

public static boolean handleRichPush(android.app.Activity pushActivity)
                              throws NetmeraException
If the coming push notification is rich, the method creates a web view and loads the content of the notification. If the notification is standard, it does nothing.

Parameters:
pushActivity - Activity class which was used while registering the device
Returns:
returns false if the notification is a basic one, true otherwise
Throws:
NetmeraException - Throws exception if it cannot access server

handleRichPush

public static boolean handleRichPush(android.app.Activity pushActivity,
                                     NetmeraJavascriptInterface javascriptInterface)
                              throws NetmeraException
If the coming push notification is rich, the method creates a web view, adds given javascriptInterface to the web view and loads the content of the notification. If the notification is standard, it does nothing.

Parameters:
pushActivity - Activity class which was used while registering the device
javascriptInterface - A NetmeraJavascriptInterface object that is injected into created webview
Returns:
returns false if the notification is a basic one, true otherwise
Throws:
NetmeraException - Throws exception if it cannot access server

handleRichPush

public static boolean handleRichPush(android.app.Activity pushActivity,
                                     java.util.List<NetmeraJavascriptInterface> javascriptInterfaces)
                              throws NetmeraException
If the coming push notification is rich, the method creates a web view, adds given list of javascriptInterfaces to the web view and loads the content of the notification. If the notification is standard, it does nothing.

Parameters:
pushActivity - Activity class which was used while registering the device
javascriptInterfaces - A list of NetmeraJavascriptInterface objects that is injected into created web view
Returns:
returns false if the notification is a basic one, true otherwise
Throws:
NetmeraException - Throws exception if it cannot access server

enablePushInbox

public static void enablePushInbox()
                            throws NetmeraException
Enables push inbox.

Throws:
NetmeraException - if your Netmera api key is missing.

disablePushInbox

public static void disablePushInbox()
                             throws NetmeraException
Disables push inbox.

Throws:
NetmeraException - if your Netmera api key is missing.