1 package expo.modules.notifications.notifications.model; 2 3 import android.os.Parcel; 4 import android.os.Parcelable; 5 6 /** 7 * A POJO representing user's response to a notification. It may be a default action, 8 * i.e. a tap on the notification ({@link #DEFAULT_ACTION_IDENTIFIER}). 9 */ 10 public class NotificationResponse implements Parcelable { 11 public static final String DEFAULT_ACTION_IDENTIFIER = "expo.modules.notifications.actions.DEFAULT"; 12 13 private NotificationAction mAction; 14 private Notification mNotification; 15 NotificationResponse(NotificationAction action, Notification notification)16 public NotificationResponse(NotificationAction action, Notification notification) { 17 mAction = action; 18 mNotification = notification; 19 } 20 getAction()21 public NotificationAction getAction() { 22 return mAction; 23 } 24 getActionIdentifier()25 public String getActionIdentifier() { 26 return mAction.getIdentifier(); 27 } 28 getNotification()29 public Notification getNotification() { 30 return mNotification; 31 } 32 33 public static final Creator<NotificationResponse> CREATOR = new Creator<NotificationResponse>() { 34 @Override 35 public NotificationResponse createFromParcel(Parcel in) { 36 return new NotificationResponse(in); 37 } 38 39 @Override 40 public NotificationResponse[] newArray(int size) { 41 return new NotificationResponse[size]; 42 } 43 }; 44 45 @Override describeContents()46 public int describeContents() { 47 return 0; 48 } 49 NotificationResponse(Parcel in)50 protected NotificationResponse(Parcel in) { 51 mAction = in.readParcelable(getClass().getClassLoader()); 52 mNotification = in.readParcelable(getClass().getClassLoader()); 53 } 54 55 @Override writeToParcel(Parcel dest, int flags)56 public void writeToParcel(Parcel dest, int flags) { 57 dest.writeParcelable(mAction, 0); 58 dest.writeParcelable(mNotification, 0); 59 } 60 } 61