Package im.getsocial.sdk
Class Notifications
- java.lang.Object
-
- im.getsocial.sdk.Notifications
-
public final class Notifications extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
arePushNotificationsEnabled(Callback<java.lang.Boolean> callback, FailureCallback failure)
Check if PNs are enabled for current user.static void
get(PagingQuery<NotificationsQuery> query, Callback<PagingResult<Notification>> callback, FailureCallback failure)
Get the list of notifications for current user.static void
getCount(NotificationsQuery query, Callback<java.lang.Integer> callback, FailureCallback failure)
Get a number of notifications for current user.static void
registerDevice()
If autoRegisterForPush meta property is set to false in the getsocial.json, call this method to register for push notifications.static void
send(NotificationContent notificationContent, SendNotificationTarget target, CompletionCallback callback, FailureCallback failure)
Send notification to any GetSocial user.static void
setOnNotificationClickedListener(OnNotificationClickedListener listener)
Set a notification listener, you can handle a click on notification inOnNotificationClickedListener.onNotificationClicked(Notification, NotificationContext)
method.static void
setOnNotificationReceivedListener(OnNotificationReceivedListener listener)
Set a notification listener, you can handle notification while application is in foreground.static void
setOnTokenReceivedListener(OnTokenReceivedListener listener)
Set a listener to be called when Push Notifications token obtained by GetSocial.static void
setPushNotificationsEnabled(boolean isEnabled, CompletionCallback completionCallback, FailureCallback failure)
If set to `false` - current user won't receive GetSocial notifications anymore, until called with `true`.static void
setStatus(java.lang.String status, java.util.List<java.lang.String> notificationIds, CompletionCallback callback, FailureCallback failure)
Set notifications status to one ofNotificationStatus
.
-
-
-
Method Detail
-
registerDevice
public static void registerDevice()
If autoRegisterForPush meta property is set to false in the getsocial.json, call this method to register for push notifications.
-
setOnNotificationClickedListener
public static void setOnNotificationClickedListener(OnNotificationClickedListener listener)
Set a notification listener, you can handle a click on notification inOnNotificationClickedListener.onNotificationClicked(Notification, NotificationContext)
method.- Parameters:
listener
- An object that will be notified with clicked notification.
-
setOnNotificationReceivedListener
public static void setOnNotificationReceivedListener(OnNotificationReceivedListener listener)
Set a notification listener, you can handle notification while application is in foreground.- Parameters:
listener
- An object that will be notified with received notification.
-
setOnTokenReceivedListener
public static void setOnTokenReceivedListener(OnTokenReceivedListener listener)
Set a listener to be called when Push Notifications token obtained by GetSocial.- Parameters:
listener
- An object that will be notified with push token.
-
get
public static void get(PagingQuery<NotificationsQuery> query, Callback<PagingResult<Notification>> callback, FailureCallback failure)
Get the list of notifications for current user.- Parameters:
query
- Notifications query.callback
- Callback to be invoked with a list of notifications.failure
- Called if operation failed.
-
getCount
public static void getCount(NotificationsQuery query, Callback<java.lang.Integer> callback, FailureCallback failure)
Get a number of notifications for current user.- Parameters:
query
- Notifications count query.callback
- Callback to be invoked with a number of notifications.failure
- Called if operation failed.
-
setStatus
public static void setStatus(java.lang.String status, java.util.List<java.lang.String> notificationIds, CompletionCallback callback, FailureCallback failure)
Set notifications status to one ofNotificationStatus
.- Parameters:
status
- One ofNotificationStatus
.notificationIds
- List of notifications IDs to change the read status.callback
- A callback to indicate if this operation was successful.failure
- Called if operation failed.
-
send
public static void send(NotificationContent notificationContent, SendNotificationTarget target, CompletionCallback callback, FailureCallback failure)
Send notification to any GetSocial user. Also you can use placeholders:SendNotificationPlaceholders.Receivers
.- Parameters:
notificationContent
- Content of push notification.target
- List of user IDs or placeholders who will receive the notification.callback
- Notifies if operation was successful.failure
- Called if operation failed.
-
setPushNotificationsEnabled
public static void setPushNotificationsEnabled(boolean isEnabled, CompletionCallback completionCallback, FailureCallback failure)
If set to `false` - current user won't receive GetSocial notifications anymore, until called with `true`.- Parameters:
isEnabled
- Disabled or enable PNs.completionCallback
- A callback to indicate if this operation was successful.failure
- Called if operation failed.
-
arePushNotificationsEnabled
public static void arePushNotificationsEnabled(Callback<java.lang.Boolean> callback, FailureCallback failure)
Check if PNs are enabled for current user.- Parameters:
callback
- Called with `true` if is enabled, with `false` otherwise.failure
- Called if operation failed.
-
-