code: @Override
  	public void onReceiveNotification(ApptentiveNotification notification) {
  		checkConversationQueue();
  
  		if (notification.hasName(NOTIFICATION_ACTIVITY_STARTED) ||
  			notification.hasName(NOTIFICATION_ACTIVITY_RESUMED)) {
  			final Activity activity = notification.getRequiredUserInfo(NOTIFICATION_KEY_ACTIVITY, Activity.class);
  			setCurrentForegroundActivity(activity);
  		} else if (notification.hasName(NOTIFICATION_APP_ENTERED_FOREGROUND)) {
  			appWentToForeground();
  		} else if (notification.hasName(NOTIFICATION_APP_ENTERED_BACKGROUND)) {
  			setCurrentForegroundActivity(null);
  			appWentToBackground();
  		} else if (notification.hasName(NOTIFICATION_PAYLOAD_WILL_START_SEND)) {
  			final PayloadData payload = notification.getRequiredUserInfo(NOTIFICATION_KEY_PAYLOAD, PayloadData.class);
  			if (payload.getType().equals(PayloadType.message)) {
  				resumeSending();
  			}
  		} else if (notification.hasName(NOTIFICATION_PAYLOAD_DID_FINISH_SEND)) {
  			final boolean successful = notification.getRequiredUserInfo(NOTIFICATION_KEY_SUCCESSFUL, Boolean.class);
  			final PayloadData payload = notification.getRequiredUserInfo(NOTIFICATION_KEY_PAYLOAD, PayloadData.class);
  			final Integer responseCode = notification.getRequiredUserInfo(NOTIFICATION_KEY_RESPONSE_CODE, Integer.class);
  			final JSONObject responseData = successful ? notification.getRequiredUserInfo(NOTIFICATION_KEY_RESPONSE_DATA, JSONObject.class) : null;
  			if (responseCode == -1) {
  				pauseSending(SEND_PAUSE_REASON_NETWORK);
  			}
  
  			if (payload.getType().equals(PayloadType.message)) {
  				onSentMessage(payload.getNonce(), responseCode, responseData);
  			}
  		}
  	}
docs: region Notification Observer