diff --git a/app/src/main/java/com/enaboapps/switchify/service/custom/actions/store/ActionStore.kt b/app/src/main/java/com/enaboapps/switchify/service/custom/actions/store/ActionStore.kt index 5ffb0f11..677ade92 100644 --- a/app/src/main/java/com/enaboapps/switchify/service/custom/actions/store/ActionStore.kt +++ b/app/src/main/java/com/enaboapps/switchify/service/custom/actions/store/ActionStore.kt @@ -154,7 +154,7 @@ class ActionStore(private val context: Context) { id = data["id"] as? String ?: return@mapNotNull null, action = data["action"] as? String ?: return@mapNotNull null, text = data["text"] as? String ?: return@mapNotNull null, - extra = data["extra"] as? ActionExtra + extra = ActionExtra.fromFirestore(data) ) } catch (e: Exception) { Log.e(tag, "Error parsing remote action: ${e.message}") diff --git a/app/src/main/java/com/enaboapps/switchify/service/custom/actions/store/data/ActionExtra.kt b/app/src/main/java/com/enaboapps/switchify/service/custom/actions/store/data/ActionExtra.kt index 09b4475b..197d36b7 100644 --- a/app/src/main/java/com/enaboapps/switchify/service/custom/actions/store/data/ActionExtra.kt +++ b/app/src/main/java/com/enaboapps/switchify/service/custom/actions/store/data/ActionExtra.kt @@ -16,6 +16,20 @@ data class ActionExtra( companion object { fun fromJson(json: String): ActionExtra = Gson().fromJson(json, ActionExtra::class.java) + + fun fromFirestore(document: Map): ActionExtra { + val data = document["extra"] as? Map<*, *> ?: return ActionExtra() + return ActionExtra( + appName = data["appName"] as? String ?: "", + appPackage = data["appPackage"] as? String ?: "", + textToCopy = data["textToCopy"] as? String ?: "", + numberToCall = data["numberToCall"] as? String ?: "", + linkUrl = data["linkUrl"] as? String ?: "", + numberToSend = data["numberToSend"] as? String ?: "", + message = data["message"] as? String ?: "", + emailAddress = data["emailAddress"] as? String ?: "" + ) + } } fun toJson(): String = Gson().toJson(this)