private void handleConversationStateChange ( Conversation conversation ) { ApptentiveLog . d ( CONVERSATION , "Conversation state changed: %s" , conversation ) ; checkConversationQueue ( ) ; assertTrue ( conversation != null && ! conversation . hasState ( UNDEFINED ) ) ; if ( conversation != null && ! conversation . hasState ( UNDEFINED ) ) { ApptentiveNotificationCenter . defaultCenter ( ) . postNotification ( NOTIFICATION_CONVERSATION_STATE_DID_CHANGE , NOTIFICATION_KEY_CONVERSATION , conversation ) ; if ( conversation . hasActiveState ( ) ) { if ( appIsInForeground ) { // ConversationManager listens to the foreground event to fetch interactions when it comes to foreground conversation . fetchInteractions ( getContext ( ) ) ; // Message Manager listens to foreground/background events itself conversation . getMessageManager ( ) . attemptToStartMessagePolling ( ) ; } // Fetch app configuration fetchAppConfiguration ( conversation ) ; // Update conversation with push configuration changes that happened while it wasn't active. SharedPreferences prefs = ApptentiveInternal . getInstance ( ) . getGlobalSharedPrefs ( ) ; int pushProvider = prefs . getInt ( Constants . PREF_KEY_PUSH_PROVIDER , - 1 ) ; String pushToken = prefs . getString ( Constants . PREF_KEY_PUSH_TOKEN , null ) ; if ( pushProvider != - 1 && pushToken != null ) { conversation . setPushIntegration ( pushProvider , pushToken ) ; } } updateMetadataItems ( conversation ) ; if ( ApptentiveLog . canLog ( VERBOSE ) ) { printMetadata ( conversationMetadata , "Updated Metadata" ) ; } } }
region Conversation fetching