From d976ab31c65dc5a56c50e141ff4cb0237574d0ac Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 26 Jun 2024 11:48:19 -0700 Subject: [PATCH] finish android impl --- ...ExpoBackgroundNotificationHandlerModule.kt | 24 +++++++++++++------ ...oBackgroundNotificationHandlerModule.swift | 10 ++++---- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/modules/expo-background-notification-handler/android/src/main/java/expo/modules/backgroundnotificationhandler/ExpoBackgroundNotificationHandlerModule.kt b/modules/expo-background-notification-handler/android/src/main/java/expo/modules/backgroundnotificationhandler/ExpoBackgroundNotificationHandlerModule.kt index a6068c0ca5..eb14c7493e 100644 --- a/modules/expo-background-notification-handler/android/src/main/java/expo/modules/backgroundnotificationhandler/ExpoBackgroundNotificationHandlerModule.kt +++ b/modules/expo-background-notification-handler/android/src/main/java/expo/modules/backgroundnotificationhandler/ExpoBackgroundNotificationHandlerModule.kt @@ -29,11 +29,7 @@ class ExpoBackgroundNotificationHandlerModule : Module() { if (Preferences(context).hasValue(key)) { return@forEach } - - Preferences(context)._(key, value) - - when (value) { - } + Preferences(context)._setAnyValue(key, value) } } @@ -45,8 +41,22 @@ class ExpoBackgroundNotificationHandlerModule : Module() { isForegrounded = false } - AsyncFunction("setBadgeCountAsync") { _: String, _: Int -> - // This does nothing on Android + AsyncFunction("getPrefsAsync") { + val context = appContext.reactContext ?: throw Error("Context is null") + val keys = DEFAULTS.keys + return@AsyncFunction Preferences(context).getValues(keys) + } + + AsyncFunction("resetGenericCountAsync") { + // Not implemented + } + + AsyncFunction("maybeIncrementMessagesCountAsync") { + // Not implemented + } + + AsyncFunction("maybeDecrementMessagesCountAsync") { + // Not implemented } } } diff --git a/modules/expo-background-notification-handler/ios/ExpoBackgroundNotificationHandlerModule.swift b/modules/expo-background-notification-handler/ios/ExpoBackgroundNotificationHandlerModule.swift index 2131ada491..c38bb669f4 100644 --- a/modules/expo-background-notification-handler/ios/ExpoBackgroundNotificationHandlerModule.swift +++ b/modules/expo-background-notification-handler/ios/ExpoBackgroundNotificationHandlerModule.swift @@ -37,6 +37,11 @@ public class ExpoBackgroundNotificationHandlerModule: Module { } } + AsyncFunction("getPrefsAsync") { + let keys = Array(DEFAULTS.keys) + return SharedPrefs.shared.getValues(keys) + } + AsyncFunction("resetGenericCountAsync") { SharedPrefs.shared.setValue(BadgeType.generic.toKeyName(), 0) } @@ -66,11 +71,6 @@ public class ExpoBackgroundNotificationHandlerModule: Module { SharedPrefs.shared.setValue(BadgeType.messages.toKeyName(), count) return true } - - AsyncFunction("getPrefsAsync") { - let keys = Array(DEFAULTS.keys) - return SharedPrefs.shared.getValues(keys) - } } }