Skip to content

Commit

Permalink
Add basic embedded isReady support (#50)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Ryan Lepinski <[email protected]>
  • Loading branch information
3 people authored Aug 29, 2024
1 parent ef357bc commit 3b8b570
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 24 deletions.
2 changes: 1 addition & 1 deletion AirshipFrameworkProxy.podspec
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -39,7 +36,6 @@ internal class AirshipListener(
AirshipChannelListener,
InboxListener
{

private val isAppForegrounded: Boolean
get() {
return GlobalActivityMonitor.shared(UAirship.getApplicationContext()).isAppForegrounded
Expand Down Expand Up @@ -122,4 +118,5 @@ internal class AirshipListener(
)
)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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<AirshipEmbeddedInfo>) : Event {
override val type = EventType.PENDING_EMBEDDED_UPDATED

override val body: JsonMap = jsonMapOf(
"pending" to pending.map { jsonMapOf( "embeddedId" to it.embeddedId ) }
)
}
2 changes: 1 addition & 1 deletion android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]

# Airship
airshipProxy = '7.1.2'
airshipProxy = '7.2.0'
airship = '18.1.6'

# Gradle plugins
Expand Down
6 changes: 5 additions & 1 deletion ios/AirshipFrameworkProxy/AirshipDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -26,6 +28,9 @@ class AirshipDelegate: NSObject,
) {
self.proxyStore = proxyStore
self.eventEmitter = eventEmitter


super.init()
}

func displayMessageCenter(messageID: String) {
Expand Down Expand Up @@ -93,7 +98,6 @@ class AirshipDelegate: NSObject,
DeepLinkEvent(deepLink)
)
}


func messageCenterInboxUpdated() {
Task {
Expand Down
12 changes: 12 additions & 0 deletions ios/AirshipFrameworkProxy/AirshipProxyEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public enum AirshipProxyEventType: CaseIterable, Equatable, Sendable {
case pushReceived
case notificationStatusChanged
case authorizedNotificationSettingsChanged

case pendingEmbeddedUpdated
}

public protocol AirshipProxyEvent {
Expand Down Expand Up @@ -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] }
]
}
}

11 changes: 11 additions & 0 deletions ios/AirshipFrameworkProxy/Proxies/AirshipProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 16 additions & 16 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3b8b570

Please sign in to comment.