From e0861bf29a6688195019cd74c6f81c61a24ff0a5 Mon Sep 17 00:00:00 2001 From: Isidro Henoch Date: Sat, 19 Feb 2022 13:57:27 -0600 Subject: Register the APNs token to receive fcm notifications --- iosApp/iosApp/AppDelegate.swift | 8 ++++++++ 1 file changed, 8 insertions(+) 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 { -- cgit v1.2.3 From efd939e18cf3eab8db0146f8428c58f3cf14a185 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Sat, 19 Feb 2022 23:20:51 -0600 Subject: Fixed registerFcmToken() accidentally adding quotes to previous tokens --- .../kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3 From dfd9ba657b93a6f5b98246f6d174e02cc4132d46 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Sat, 19 Feb 2022 23:31:48 -0600 Subject: Xcode did this --- iosApp/iosApp/Info.plist | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iosApp/iosApp/Info.plist b/iosApp/iosApp/Info.plist index bf9db74..99c8b7b 100644 --- a/iosApp/iosApp/Info.plist +++ b/iosApp/iosApp/Info.plist @@ -4,10 +4,6 @@ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) - UIBackgroundModes - - remote-notification - CFBundleDisplayName TrackerMap CFBundleExecutable @@ -31,6 +27,10 @@ UIApplicationSupportsMultipleScenes + UIBackgroundModes + + remote-notification + UILaunchScreen UIRequiredDeviceCapabilities -- cgit v1.2.3