From 3b8b57050a0f5f1cfbcce4c16607ab13020238fb Mon Sep 17 00:00:00 2001 From: David Date: Thu, 29 Aug 2024 16:06:32 -0700 Subject: [PATCH] Add basic embedded isReady support (#50) * Add basic ios embedded isReady support * Start android and proxy updates * Remove EmbeddedInfo intermediate * Add android * Move ios embedded listener * Release 7.2.0 --------- Co-authored-by: crow Co-authored-by: Ryan Lepinski --- AirshipFrameworkProxy.podspec | 2 +- .../framework/proxy/AirshipListener.kt | 5 +-- .../android/framework/proxy/BaseAutopilot.kt | 10 ++++++ .../android/framework/proxy/events/Event.kt | 3 +- .../proxy/events/PendingEmbeddedUpdated.kt | 17 ++++++++++ android/gradle/libs.versions.toml | 2 +- .../AirshipDelegate.swift | 6 +++- .../AirshipProxyEvent.swift | 12 +++++++ .../Proxies/AirshipProxy.swift | 11 +++++++ ios/Podfile.lock | 32 +++++++++---------- 10 files changed, 76 insertions(+), 24 deletions(-) create mode 100644 android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/events/PendingEmbeddedUpdated.kt diff --git a/AirshipFrameworkProxy.podspec b/AirshipFrameworkProxy.podspec index 36eb476..b7e9622 100644 --- a/AirshipFrameworkProxy.podspec +++ b/AirshipFrameworkProxy.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| - s.version = "7.1.2" + s.version = "7.2.0" s.name = "AirshipFrameworkProxy" s.summary = "Airship iOS mobile framework proxy" s.documentation_url = "https://docs.airship.com/platform/mobile" diff --git a/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/AirshipListener.kt b/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/AirshipListener.kt index afac1b0..b51003b 100644 --- a/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/AirshipListener.kt +++ b/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/AirshipListener.kt @@ -9,7 +9,6 @@ import com.urbanairship.android.framework.proxy.events.DisplayPreferenceCenterEv import com.urbanairship.android.framework.proxy.events.EventEmitter import com.urbanairship.android.framework.proxy.events.MessageCenterUpdatedEvent import com.urbanairship.android.framework.proxy.events.NotificationResponseEvent -import com.urbanairship.android.framework.proxy.events.NotificationStatusEvent import com.urbanairship.android.framework.proxy.events.PushReceivedEvent import com.urbanairship.android.framework.proxy.events.PushTokenReceivedEvent import com.urbanairship.app.GlobalActivityMonitor @@ -22,8 +21,6 @@ import com.urbanairship.push.NotificationInfo import com.urbanairship.push.NotificationListener import com.urbanairship.push.PushListener import com.urbanairship.push.PushMessage -import com.urbanairship.push.PushNotificationStatus -import com.urbanairship.push.PushNotificationStatusListener import com.urbanairship.push.PushTokenListener internal class AirshipListener( @@ -39,7 +36,6 @@ internal class AirshipListener( AirshipChannelListener, InboxListener { - private val isAppForegrounded: Boolean get() { return GlobalActivityMonitor.shared(UAirship.getApplicationContext()).isAppForegrounded @@ -122,4 +118,5 @@ internal class AirshipListener( ) ) } + } diff --git a/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/BaseAutopilot.kt b/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/BaseAutopilot.kt index 5f9b5c9..d526efc 100644 --- a/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/BaseAutopilot.kt +++ b/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/BaseAutopilot.kt @@ -14,7 +14,9 @@ import com.urbanairship.android.framework.proxy.Utils.getHexColor import com.urbanairship.android.framework.proxy.Utils.getNamedResource import com.urbanairship.android.framework.proxy.events.EventEmitter import com.urbanairship.android.framework.proxy.events.NotificationStatusEvent +import com.urbanairship.android.framework.proxy.events.PendingEmbeddedUpdated import com.urbanairship.android.framework.proxy.proxies.AirshipProxy +import com.urbanairship.embedded.AirshipEmbeddedObserver import com.urbanairship.messagecenter.MessageCenter import com.urbanairship.preferencecenter.PreferenceCenter import com.urbanairship.push.pushNotificationStatusFlow @@ -58,6 +60,14 @@ public abstract class BaseAutopilot : Autopilot() { airship.pushManager.notificationListener = airshipListener airship.deepLinkListener = airshipListener + dispatcher.launch { + AirshipEmbeddedObserver().embeddedViewInfoFlow.collect { + EventEmitter.shared().addEvent( + PendingEmbeddedUpdated(it) + ) + } + } + dispatcher.launch { airship.pushManager.pushNotificationStatusFlow .map { NotificationStatus(it) } diff --git a/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/events/Event.kt b/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/events/Event.kt index 175aa6c..993529e 100644 --- a/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/events/Event.kt +++ b/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/events/Event.kt @@ -15,7 +15,8 @@ public enum class EventType { BACKGROUND_NOTIFICATION_RESPONSE_RECEIVED, FOREGROUND_PUSH_RECEIVED, BACKGROUND_PUSH_RECEIVED, - NOTIFICATION_STATUS_CHANGED + NOTIFICATION_STATUS_CHANGED, + PENDING_EMBEDDED_UPDATED } /** diff --git a/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/events/PendingEmbeddedUpdated.kt b/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/events/PendingEmbeddedUpdated.kt new file mode 100644 index 0000000..2586885 --- /dev/null +++ b/android/airship-framework-proxy/src/main/java/com/urbanairship/android/framework/proxy/events/PendingEmbeddedUpdated.kt @@ -0,0 +1,17 @@ +/* Copyright Urban Airship and Contributors */ + +package com.urbanairship.android.framework.proxy.events + +import com.urbanairship.android.framework.proxy.Event +import com.urbanairship.android.framework.proxy.EventType +import com.urbanairship.embedded.AirshipEmbeddedInfo +import com.urbanairship.json.JsonMap +import com.urbanairship.json.jsonMapOf + +internal class PendingEmbeddedUpdated(pending: List) : Event { + override val type = EventType.PENDING_EMBEDDED_UPDATED + + override val body: JsonMap = jsonMapOf( + "pending" to pending.map { jsonMapOf( "embeddedId" to it.embeddedId ) } + ) +} diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml index efc14e6..38a05d2 100644 --- a/android/gradle/libs.versions.toml +++ b/android/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] # Airship -airshipProxy = '7.1.2' +airshipProxy = '7.2.0' airship = '18.1.6' # Gradle plugins diff --git a/ios/AirshipFrameworkProxy/AirshipDelegate.swift b/ios/AirshipFrameworkProxy/AirshipDelegate.swift index 1f5fc25..a705d0e 100644 --- a/ios/AirshipFrameworkProxy/AirshipDelegate.swift +++ b/ios/AirshipFrameworkProxy/AirshipDelegate.swift @@ -3,10 +3,12 @@ import Foundation #if canImport(AirshipKit) import AirshipKit +import Combine #elseif canImport(AirshipCore) import AirshipCore import AirshipMessageCenter import AirshipPreferenceCenter +import AirshipAutomation #endif class AirshipDelegate: NSObject, @@ -26,6 +28,9 @@ class AirshipDelegate: NSObject, ) { self.proxyStore = proxyStore self.eventEmitter = eventEmitter + + + super.init() } func displayMessageCenter(messageID: String) { @@ -93,7 +98,6 @@ class AirshipDelegate: NSObject, DeepLinkEvent(deepLink) ) } - func messageCenterInboxUpdated() { Task { diff --git a/ios/AirshipFrameworkProxy/AirshipProxyEvent.swift b/ios/AirshipFrameworkProxy/AirshipProxyEvent.swift index 386be8a..99ed578 100644 --- a/ios/AirshipFrameworkProxy/AirshipProxyEvent.swift +++ b/ios/AirshipFrameworkProxy/AirshipProxyEvent.swift @@ -20,6 +20,8 @@ public enum AirshipProxyEventType: CaseIterable, Equatable, Sendable { case pushReceived case notificationStatusChanged case authorizedNotificationSettingsChanged + + case pendingEmbeddedUpdated } public protocol AirshipProxyEvent { @@ -163,4 +165,14 @@ struct AuthorizedNotificationSettingsChangedEvent: AirshipProxyEvent { } +struct EmbeddedInfoUpdatedEvent: AirshipProxyEvent { + let type: AirshipProxyEventType = .pendingEmbeddedUpdated + let body: [String: Any] + + init(pending: [AirshipEmbeddedInfo]) { + self.body = [ + "pending": pending.map { ["embeddedId": $0.embeddedID] } + ] + } +} diff --git a/ios/AirshipFrameworkProxy/Proxies/AirshipProxy.swift b/ios/AirshipFrameworkProxy/Proxies/AirshipProxy.swift index 5783921..7597cc4 100644 --- a/ios/AirshipFrameworkProxy/Proxies/AirshipProxy.swift +++ b/ios/AirshipFrameworkProxy/Proxies/AirshipProxy.swift @@ -202,6 +202,17 @@ public class AirshipProxy { } .store(in: &self.subscriptions) + + AirshipEmbeddedObserver().$embeddedInfos.sink { embeddedInfos in + Task { + await AirshipProxyEventEmitter.shared.addEvent( + EmbeddedInfoUpdatedEvent( + pending: embeddedInfos + ) + ) + } + }.store(in: &self.subscriptions) + NotificationCenter.default.addObserver( forName: AirshipNotifications.MessageCenterListUpdated.name, object: nil, diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 4ce3404..52c8694 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,33 +1,33 @@ PODS: - - Airship (18.4.1): - - Airship/Automation (= 18.4.1) - - Airship/Basement (= 18.4.1) - - Airship/Core (= 18.4.1) - - Airship/FeatureFlags (= 18.4.1) - - Airship/MessageCenter (= 18.4.1) - - Airship/PreferenceCenter (= 18.4.1) - - Airship/Automation (18.4.1): + - Airship (18.7.2): + - Airship/Automation (= 18.7.2) + - Airship/Basement (= 18.7.2) + - Airship/Core (= 18.7.2) + - Airship/FeatureFlags (= 18.7.2) + - Airship/MessageCenter (= 18.7.2) + - Airship/PreferenceCenter (= 18.7.2) + - Airship/Automation (18.7.2): - Airship/Core - - Airship/Basement (18.4.1) - - Airship/Core (18.4.1): + - Airship/Basement (18.7.2) + - Airship/Core (18.7.2): - Airship/Basement - - Airship/FeatureFlags (18.4.1): + - Airship/FeatureFlags (18.7.2): - Airship/Core - - Airship/MessageCenter (18.4.1): + - Airship/MessageCenter (18.7.2): - Airship/Core - - Airship/PreferenceCenter (18.4.1): + - Airship/PreferenceCenter (18.7.2): - Airship/Core DEPENDENCIES: - - Airship (= 18.4.1) + - Airship (= 18.7.2) SPEC REPOS: trunk: - Airship SPEC CHECKSUMS: - Airship: 4c99ee58d4441c63ab9c058d5e800cdaa4b7f8d3 + Airship: bb32ff2c5a811352da074480357d9f02dbb8f327 -PODFILE CHECKSUM: 635ef5c49183fa89abcb3d354a52a08af305b7bc +PODFILE CHECKSUM: 22c784850a9675e3098beb50f7466412a5aaef79 COCOAPODS: 1.15.2