final Sdk sdk = SdkManager.generateCurrentSdk(getContext()); final Device device = DeviceManager.generateNewDevice(getContext());
private @Nullable Conversation loadActiveConversationGuarded() throws ConversationLoadException { // try to load an active conversation from metadata first try { if (conversationMetadata.hasItems()) { return loadConversationFromMetadata(conversationMetadata); } // try to load legacy conversation Conversation legacyConversation = migrateLegacyConversation(getContext()); if (legacyConversation != null) { return legacyConversation; } } catch (Exception e) { ApptentiveLog.e(e, "Exception while loading conversation"); logException(e); // do not re-create a conversation if the last loading was unsuccessful throw new ConversationLoadException("Unable to load conversation", e); } // no active conversations: create a new one ApptentiveLog.i(CONVERSATION, "Creating 'anonymous' conversation..."); File dataFile = generateConversationDataFilename(); File messagesFile = generateMessagesFilename(); Conversation conversation = new Conversation(dataFile, messagesFile, encryptionKey); conversation.setState(ANONYMOUS_PENDING); fetchConversationToken(conversation); return conversation; }
if (appIsInForeground) { conversation.fetchInteractions(getContext());
public void logout() { checkConversationQueue(); if (activeConversation != null) { switch (activeConversation.getState()) { case LOGGED_IN: ApptentiveLog.d(CONVERSATION, "Ending active conversation."); EngagementModule.engageInternal(getContext(), activeConversation, "logout"); // Post synchronously to ensure logout payload can be sent before destroying the logged in conversation. ApptentiveNotificationCenter.defaultCenter().postNotification(NOTIFICATION_CONVERSATION_WILL_LOGOUT, ObjectUtils.toMap(NOTIFICATION_KEY_CONVERSATION, activeConversation)); activeConversation.destroy(); activeConversation.setState(LOGGED_OUT); handleConversationStateChange(activeConversation); setActiveConversation(null); ApptentiveInternal.dismissAllInteractions(); break; default: ApptentiveLog.w(CONVERSATION, "Attempted to logout() from Conversation, but the Active Conversation was not in LOGGED_IN state."); break; } } else { ApptentiveLog.w(CONVERSATION, "Attempted to logout(), but there was no Active Conversation."); } }
boolean debuggable = RuntimeUtils.isAppDebuggable(getContext()); if (!debuggable) { ApptentiveLog.d(APP_CONFIGURATION, "Can't fetch app configuration: the old configuration is still valid");
final Context context = getContext(); if (context == null) { ApptentiveLog.w(CONVERSATION, "Unable to fetch conversation token: context reference is lost");