load preferences
This commit is contained in:
+5
@@ -64,6 +64,11 @@ public class ExpoBackgroundNotificationHandlerModule: Module {
|
||||
SharedPrefs.shared.removeFromSet(INCREMENTED_FOR_KEY, convoId)
|
||||
SharedPrefs.shared.setValue(BadgeType.messages.toKeyName(), count)
|
||||
}
|
||||
|
||||
AsyncFunction("getPrefsAsync") {
|
||||
let keys = Array(DEFAULTS.keys)
|
||||
return SharedPrefs.shared.getValues(keys)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -31,7 +31,9 @@ export function BackgroundNotificationPreferencesProvider({
|
||||
React.useEffect(() => {
|
||||
;(async () => {
|
||||
const prefs = await BackgroundNotifications.getPrefsAsync()
|
||||
setPreferences(prefs)
|
||||
if (prefs) {
|
||||
setPreferences(prefs)
|
||||
}
|
||||
})()
|
||||
}, [])
|
||||
|
||||
|
||||
@@ -19,6 +19,6 @@ export function decrementMessagesCountAsync(
|
||||
throw new NotImplementedError({count, convoId})
|
||||
}
|
||||
|
||||
export function getPrefsAsync(): Promise<BackgroundNotificationHandlerPreferences> {
|
||||
export function getPrefsAsync(): Promise<BackgroundNotificationHandlerPreferences | null> {
|
||||
throw new NotImplementedError()
|
||||
}
|
||||
|
||||
@@ -82,4 +82,8 @@ public class SharedPrefs {
|
||||
public func hasValue(_ key: String) -> Bool {
|
||||
return getDefaults(key)?.value(forKey: key) != nil
|
||||
}
|
||||
|
||||
public func getValues(_ keys: [String]) -> [String:Any?]? {
|
||||
return getDefaults("keys:\(keys)")?.dictionaryWithValues(forKeys: keys)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user