if (ChatSDK.auth() == null || !ChatSDK.auth().userAuthenticatedThisSession() || ChatSDK.config().backgroundPushTestModeEnabled) { appIntent = new Intent(context, ChatSDK.ui().getLoginActivity()); } else if (AppBackgroundMonitor.shared().inBackground() && ChatSDK.auth().userAuthenticatedThisSession()) { appIntent = new Intent(context, ChatSDK.ui().getChatActivity());
public static ChatSDK initialize (Configuration config, BaseNetworkAdapter networkAdapter, InterfaceAdapter interfaceAdapter) throws ChatSDKException { shared().setContext(config.context.get()); shared().config = config; DaoCore.init(shared().context()); if(interfaceAdapter != null) { InterfaceManager.shared().a = interfaceAdapter; } else { shared().activateModule("UserInterfaceModule", "activate", new MethodArgument(Context.class, shared().context())); } if (networkAdapter != null) { NetworkManager.shared().a = networkAdapter; } else { shared().activateModule("FirebaseModule", "activate"); } shared().handleLocalNotifications(); // Monitor the app so if it goes into the background we know AppBackgroundMonitor.shared().setEnabled(true); if (config().debug) { Timber.plant(new Timber.DebugTree()); } return shared(); }
public void handleLocalNotifications () { if (localNotificationDisposable != null) { localNotificationDisposable.dispose(); } // TODO: Check this localNotificationDisposable = ChatSDK.events().sourceOnMain() .filter(NetworkEvent.filterType(EventType.MessageAdded)) .subscribe(networkEvent -> { Message message = networkEvent.message; Thread thread = networkEvent.thread; if(message != null && !AppBackgroundMonitor.shared().inBackground()) { if (thread.typeIs(ThreadType.Private) || (thread.typeIs(ThreadType.Public) && ChatSDK.config().pushNotificationsForPublicChatRoomsEnabled)) { if(!message.getSender().isMe() && ChatSDK.ui().showLocalNotifications(message.getThread())) { ReadStatus status = message.readStatusForUser(ChatSDK.currentUser()); if (!message.isRead() && !status.is(ReadStatus.delivered())) { // Only show the alert if we'recyclerView not on the private threads tab ChatSDK.ui().notificationDisplayHandler().createMessageNotification(message); } } } } }); }