@@ -11,6 +11,7 @@ object Settings {
1111 private const val SETTINGS_ACTIVE = " SETTINGS_ACTIVE_STATUS"
1212 private const val SETTINGS_API_KEY = " SETTINGS_API_KEY"
1313 private const val SETTINGS_FCM_TOKEN = " SETTINGS_FCM_TOKEN"
14+ private const val SETTINGS_FCM_TOKEN_UPDATE_TIMESTAMP = " SETTINGS_FCM_TOKEN_UPDATE_TIMESTAMP"
1415
1516 fun getOwner (context : Context ): String? {
1617 Timber .d(Settings ::getOwner.name)
@@ -28,12 +29,38 @@ object Settings {
2829 return owner
2930 }
3031
32+ fun hasOwner (context : Context ): Boolean {
33+ return getOwner(context) != null
34+ }
35+
3136 fun getOwnerOrDefault (context : Context ): String {
3237 return getOwner(context) ? : return DEFAULT_PHONE_NUMBER
3338 }
3439
40+ fun getFcmTokenLastUpdateTimestamp (context : Context ): Long {
41+ Timber .d(Settings ::getFcmTokenLastUpdateTimestamp.name)
42+
43+ val timestamp = PreferenceManager
44+ .getDefaultSharedPreferences(context)
45+ .getLong(this .SETTINGS_FCM_TOKEN_UPDATE_TIMESTAMP ,0 )
46+
47+ Timber .d(" active status: [$timestamp ]" )
48+ return timestamp
49+ }
50+
51+
52+ fun setFcmTokenLastUpdateTimestampAsync (context : Context , timestamp : Long ) {
53+ Timber .d(Settings ::setFcmTokenLastUpdateTimestampAsync.name)
54+
55+ PreferenceManager .getDefaultSharedPreferences(context)
56+ .edit()
57+ .putLong(this .SETTINGS_FCM_TOKEN_UPDATE_TIMESTAMP , timestamp)
58+ .apply ()
59+ }
60+
61+
3562 fun setOwnerAsync (context : Context , owner : String ) {
36- Timber .d(Settings ::getOwner .name)
63+ Timber .d(Settings ::setOwnerAsync .name)
3764
3865 PreferenceManager .getDefaultSharedPreferences(context)
3966 .edit()
0 commit comments