aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--iosApp/iosApp/AppDelegate.swift8
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt4
2 files changed, 11 insertions, 1 deletions
diff --git a/iosApp/iosApp/AppDelegate.swift b/iosApp/iosApp/AppDelegate.swift
index 4233910..72e3e92 100644
--- a/iosApp/iosApp/AppDelegate.swift
+++ b/iosApp/iosApp/AppDelegate.swift
@@ -39,6 +39,14 @@ class AppDelegate: NSObject, UIApplicationDelegate {
print(userInfo)
return UIBackgroundFetchResult.newData
}
+
+ func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
+ #if DEBUG
+ Messaging.messaging().setAPNSToken(deviceToken, type: .sandbox)
+ #else
+ Messaging.messaging().setAPNSToken(deviceToken, type: .prod)
+ #endif
+ }
}
extension AppDelegate: UNUserNotificationCenterDelegate {
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt
index d3deca1..48352bf 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt
@@ -113,7 +113,7 @@ class SessionController(
try {
userFlow.value?.let { user ->
val attributes = user.attributes.toMutableMap()
- attributes["notificationTokens"].toString().let { tokens ->
+ attributes["notificationTokens"]?.content?.let { tokens ->
if (tokens == "null" || !tokens.contains(token)) {
if (tokens == "null") {
attributes["notificationTokens"] = JsonPrimitive(token)
@@ -123,6 +123,8 @@ class SessionController(
}
+ } ?: run {
+ attributes["notificationTokens"] = JsonPrimitive(token)
}
usersApi.usersIdPut(user.copy(
attributes = attributes