mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-07 09:22:30 +00:00
Utilise TokenManager and ExpiryManager
This commit is contained in:
@@ -508,7 +508,6 @@ public class ApplicationContext extends Application implements DefaultLifecycleO
|
||||
}
|
||||
|
||||
public void clearAllData(boolean isMigratingToV2KeyPair) {
|
||||
PushNotificationAPI.unregister();
|
||||
if (firebaseInstanceIdJob != null && firebaseInstanceIdJob.isActive()) {
|
||||
firebaseInstanceIdJob.cancel(null);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.thoughtcrime.securesms.notifications
|
||||
|
||||
import android.content.Context
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
|
||||
class FcmTokenManager(
|
||||
private val context: Context,
|
||||
private val expiryManager: ExpiryManager
|
||||
) {
|
||||
val isUsingFCM get() = TextSecurePreferences.isUsingFCM(context)
|
||||
|
||||
var fcmToken
|
||||
get() = TextSecurePreferences.getFCMToken(context)
|
||||
set(value) {
|
||||
TextSecurePreferences.setFCMToken(context, value)
|
||||
if (value != null) markTime() else clearTime()
|
||||
}
|
||||
|
||||
val requiresUnregister get() = fcmToken != null
|
||||
|
||||
private fun clearTime() = expiryManager.clearTime()
|
||||
private fun markTime() = expiryManager.markTime()
|
||||
private fun isExpired() = expiryManager.isExpired()
|
||||
|
||||
fun isInvalid(): Boolean = fcmToken == null || isExpired()
|
||||
}
|
||||
Reference in New Issue
Block a user