code: @Override
  	public void onReceiveNotification(ApptentiveNotification notification) {
  		checkConversationQueue();
  
  		if (notification.hasName(NOTIFICATION_CONVERSATION_STATE_DID_CHANGE)) {
  			final Conversation conversation = notification.getUserInfo(NOTIFICATION_KEY_CONVERSATION, Conversation.class);
  			assertNotNull(conversation); // sanity check
  			assertNotEquals(conversation.getState(), UNDEFINED);
  			if (conversation.hasActiveState()) {
  				final String conversationId = notNull(conversation.getConversationId());
  				final String conversationToken = notNull(conversation.getConversationToken());
  				final String conversationLocalIdentifier = notNull(conversation.getLocalIdentifier());
  				final boolean legacyPayloads = ConversationState.LEGACY_PENDING.equals(conversation.getPrevState());
  
  				ApptentiveLog.d(CONVERSATION, "Conversation %s state changed %s -> %s.", conversationId, conversation.getPrevState(), conversation.getState());
  				// when the Conversation ID comes back from the server, we need to update
  				// the payloads that may have already been enqueued so
  				// that they each have the Conversation ID.
  				if (conversation.hasState(ANONYMOUS)) {
  					singleThreadExecutor.execute(new Runnable() {
  						@Override
  						public void run() {
  							try {
  								dbHelper.updateIncompletePayloads(conversationId, conversationToken, conversationLocalIdentifier, legacyPayloads);
  								sendNextPayloadSync(); // after we've updated payloads - we need to send them
  							} catch (Exception e) {
  								ApptentiveLog.e(CONVERSATION, e, "Exception while trying to update incomplete payloads");
  								logException(e);
  							}
  						}
  					});
  				}
  			}
  		} else if (notification.hasName(NOTIFICATION_APP_ENTERED_FOREGROUND)) {
  			appInBackground = false;
  			sendNextPayload(); // when the app comes back from the background - we need to resume sending payloads
  		} else if (notification.hasName(NOTIFICATION_APP_ENTERED_BACKGROUND)) {
  			appInBackground = true;
  		}
  	}
docs: endregion