Commit 07664a60 authored by d4vidi's avatar d4vidi

Handling notification post (local notif style)

parent c28a2c9e
......@@ -18,5 +18,11 @@ public interface IPushNotification {
*/
void onOpened();
/**
* Handle a request to post this notification.
* @return ID to optionally use for notification deletion.
*/
int onPostRequest();
PushNotificationProps asProps();
}
......@@ -68,15 +68,20 @@ public class PushNotification implements IPushNotification {
PushNotificationsDrawer.get(mContext).onNotificationOpened();
}
@Override
public int onPostRequest() {
return postNotification();
}
@Override
public PushNotificationProps asProps() {
return mNotificationProps.copy();
}
protected void postNotification() {
protected int postNotification() {
final PendingIntent pendingIntent = getCTAPendingIntent();
final Notification notification = buildNotification(pendingIntent);
postNotification((int) System.currentTimeMillis(), notification);
return postNotification(notification);
}
protected void digestNotification() {
......@@ -141,11 +146,21 @@ public class PushNotification implements IPushNotification {
.setAutoCancel(true);
}
protected int postNotification(Notification notification) {
int id = createNotificationId(notification);
postNotification(id, notification);
return id;
}
protected void postNotification(int id, Notification notification) {
final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(id, notification);
}
protected int createNotificationId(Notification notification) {
return (int) System.currentTimeMillis();
}
protected ReactContext getRunningReactContext() {
final ReactNativeHost rnHost = ((ReactApplication) mContext.getApplicationContext()).getReactNativeHost();
if (!rnHost.hasInstance()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment