Skip to content

Commit

Permalink
Release 18.0.1 (#3038)
Browse files Browse the repository at this point in the history
* Rename id to embeddedID

* Fix frequency limit regression

* Fix codable issue if triggerSessionID is missing on prepared info

* Release 18.0.1

* Fix test
  • Loading branch information
rlepinski authored Mar 22, 2024
1 parent 4296eef commit 314551e
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Airship Sample/Airship Sample/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct HomeView: View {

@ViewBuilder
private func makeHeroImage() -> some View {
AirshipEmbeddedView(id: "home_hero") {
AirshipEmbeddedView(embeddedID: "home_hero") {
Image("HomeHeroImage")
.resizable()
.scaledToFit()
Expand Down
2 changes: 1 addition & 1 deletion Airship.podspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AIRSHIP_VERSION="18.0.0"
AIRSHIP_VERSION="18.0.1"

Pod::Spec.new do |s|
s.version = AIRSHIP_VERSION
Expand Down
4 changes: 4 additions & 0 deletions Airship/Airship.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,7 @@
6EDE5F4F2BA248FF00E33D04 /* TouchViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EDE5F4E2BA248FF00E33D04 /* TouchViewModifier.swift */; };
6EDE5F502BA248FF00E33D04 /* TouchViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EDE5F4E2BA248FF00E33D04 /* TouchViewModifier.swift */; };
6EDE5F512BA248FF00E33D04 /* TouchViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EDE5F4E2BA248FF00E33D04 /* TouchViewModifier.swift */; };
6EDE5FC22BADDD96003ADF55 /* PreparedScheduleInfoTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EDE5FC12BADDD96003ADF55 /* PreparedScheduleInfoTest.swift */; };
6EDF1D932B292FB100E23BC4 /* InAppMessageTextInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EDF1D922B292FB000E23BC4 /* InAppMessageTextInfo.swift */; };
6EDF1D962B2A25B400E23BC4 /* InAppMessageButtonInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EDF1D952B2A25B400E23BC4 /* InAppMessageButtonInfo.swift */; };
6EDF1D982B2A25C800E23BC4 /* InAppMessageMediaInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EDF1D972B2A25C800E23BC4 /* InAppMessageMediaInfo.swift */; };
Expand Down Expand Up @@ -2575,6 +2576,7 @@
6EDE293E2A9802BF00235738 /* NativeBridgeActionRunner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeBridgeActionRunner.swift; sourceTree = "<group>"; };
6EDE5F182B9BD7E700E33D04 /* InboxMessageData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InboxMessageData.swift; sourceTree = "<group>"; };
6EDE5F4E2BA248FF00E33D04 /* TouchViewModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TouchViewModifier.swift; sourceTree = "<group>"; };
6EDE5FC12BADDD96003ADF55 /* PreparedScheduleInfoTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreparedScheduleInfoTest.swift; sourceTree = "<group>"; };
6EDF1D922B292FB000E23BC4 /* InAppMessageTextInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppMessageTextInfo.swift; sourceTree = "<group>"; };
6EDF1D952B2A25B400E23BC4 /* InAppMessageButtonInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppMessageButtonInfo.swift; sourceTree = "<group>"; };
6EDF1D972B2A25C800E23BC4 /* InAppMessageMediaInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppMessageMediaInfo.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4388,6 +4390,7 @@
60D1D9BA2B6A53F000EBE0A4 /* PreparedTriggerTest.swift */,
60D1D9BC2B6AB2D100EBE0A4 /* AutomationTriggerProcessorTest.swift */,
A6F0B18F2B837E36002D10A4 /* AutomationEngineTest.swift */,
6EDE5FC12BADDD96003ADF55 /* PreparedScheduleInfoTest.swift */,
);
path = Engine;
sourceTree = "<group>";
Expand Down Expand Up @@ -6382,6 +6385,7 @@
files = (
6EC0CA502B4899CC00333A87 /* TestRemoteData.swift in Sources */,
6EE6AB062B59C231002FEA75 /* AirshipLayoutDisplayAdapterTest.swift in Sources */,
6EDE5FC22BADDD96003ADF55 /* PreparedScheduleInfoTest.swift in Sources */,
325D53FA29648818003421B4 /* TestAirshipRequestSession.swift in Sources */,
6E1A9BBB2B5B20D700A6489B /* TestInAppMessageAnalytics.swift in Sources */,
6E6B2DBE2B33B768008BF788 /* AutomationScheduleTest.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,28 @@ final class AutomationExecutor: AutomationExecutorProtocol {

@MainActor
func isReady(preparedSchedule: PreparedSchedule) -> ScheduleReadyResult {
if (preparedSchedule.frequencyChecker?.checkAndIncrement() == false) {
return .skip
}

switch (preparedSchedule.data) {
let result = switch (preparedSchedule.data) {
case .inAppMessage(let data):
return self.messageExecutor.isReady(
self.messageExecutor.isReady(
data: data,
preparedScheduleInfo: preparedSchedule.info
)
case .actions(let data):
return self.actionExecutor.isReady(
self.actionExecutor.isReady(
data: data,
preparedScheduleInfo: preparedSchedule.info
)
}

guard result == .ready else {
return result
}

if (preparedSchedule.frequencyChecker?.checkAndIncrement() == false) {
return .skip
}

return .ready
}

@MainActor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ struct PreparedScheduleInfo: Codable, Equatable {
self.reportingContext = reportingContext
self.triggerSessionID = triggerSessionID
}

init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.scheduleID = try container.decode(String.self, forKey: .scheduleID)
self.productID = try container.decodeIfPresent(String.self, forKey: .productID)
self.campaigns = try container.decodeIfPresent(AirshipJSON.self, forKey: .campaigns)
self.contactID = try container.decodeIfPresent(String.self, forKey: .contactID)
self.experimentResult = try container.decodeIfPresent(ExperimentResult.self, forKey: .experimentResult)
self.reportingContext = try container.decodeIfPresent(AirshipJSON.self, forKey: .reportingContext)
self.triggerSessionID = try container.decodeIfPresent(String.self, forKey: .triggerSessionID) ?? UUID().uuidString
}
}

/// Prepared schedule data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,31 @@ final class AutomationExecutorTest: XCTestCase {
}
}

func testFrequencyChekerNotCheckedIfDelegateNotReady() async throws {
let frequencyChecker = TestFrequencyChecker()

let schedule = PreparedSchedule(
info: PreparedScheduleInfo(scheduleID: UUID().uuidString, triggerSessionID: UUID().uuidString),
data: .actions(AirshipJSON.string("neat")),
frequencyChecker: frequencyChecker
)

self.actionExecutor.isReadyBlock = { _, _ in
return .notReady
}

frequencyChecker.checkAndIncrementBlock = {
return false
}

let result = await self.executor.isReady(
preparedSchedule: schedule
)

XCTAssertEqual(result, .notReady)
XCTAssertFalse(frequencyChecker.checkAndIncrementCalled)
}

func testFrequencyCheckerCheckFailed() async throws {
let frequencyChecker = TestFrequencyChecker()

Expand All @@ -94,6 +119,10 @@ final class AutomationExecutorTest: XCTestCase {
frequencyChecker: frequencyChecker
)

self.actionExecutor.isReadyBlock = { _, _ in
return .ready
}

frequencyChecker.checkAndIncrementBlock = {
return false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Copyright Airship and Contributors */

import XCTest

@testable
import AirshipAutomation

final class PreparedScheduleInfoTest: XCTestCase {
func testMissingTriggerSessionID() throws {
let json = """
{
"scheduleID": "some schedule"
}
"""

let info = try JSONDecoder().decode(
PreparedScheduleInfo.self,
from: json.data(using: .utf8)!
)

XCTAssertEqual("some schedule", info.scheduleID)
XCTAssertFalse(info.triggerSessionID.isEmpty)

}
}


2 changes: 1 addition & 1 deletion Airship/AirshipConfig.xcconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//* Copyright Airship and Contributors */

CURRENT_PROJECT_VERSION = 18.0.0
CURRENT_PROJECT_VERSION = 18.0.1

// Uncomment to include the preview build warning
// OTHER_CFLAGS = $(inherited) -DUA_PREVIEW=1
48 changes: 41 additions & 7 deletions Airship/AirshipCore/Source/AirshipEmbeddedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct AirshipEmbeddedView<PlaceHolder: View>: View {
private var viewModel: EmbeddedViewModel

private let placeholder: () -> PlaceHolder
private let id: String
private let embeddedID: String
private let embeddedSize: AirshipEmbeddedSize?

/// Creates a new AirshipEmbeddedView.
Expand All @@ -22,30 +22,64 @@ public struct AirshipEmbeddedView<PlaceHolder: View>: View {
/// - id: The embedded ID.
/// - size: The embedded size info. This is needed in a scroll view to determine proper percent based sizing.
/// - placeholder: The place holder block.
@available(*, deprecated, message: "use init(embeddedID:embeddedSize:placeHolder:) instead")
public init(
id: String,
embeddedSize: AirshipEmbeddedSize? = nil,
@ViewBuilder placeholder: @escaping () -> PlaceHolder = { EmptyView()}
) {
self.id = id
self.embeddedID = id
self.embeddedSize = embeddedSize
self.placeholder = placeholder
self._viewModel = StateObject(wrappedValue: EmbeddedViewModel(id: id))
self._viewModel = StateObject(wrappedValue: EmbeddedViewModel(embeddedID: id))
}

/// Creates a new AirshipEmbeddedView.
///
/// - Parameters:
/// - id: The embedded ID.
/// - size: The embedded size info. This is needed in a scroll view to determine proper percent based sizing.
@available(*, deprecated, message: "use init(embeddedID:embeddedSize:) instead")
public init(
id: String,
embeddedSize: AirshipEmbeddedSize? = nil
) where PlaceHolder == EmptyView {
self.id = id
self.embeddedID = id
self.embeddedSize = embeddedSize
self.placeholder = { EmptyView() }
self._viewModel = StateObject(wrappedValue: EmbeddedViewModel(id: id))
self._viewModel = StateObject(wrappedValue: EmbeddedViewModel(embeddedID: id))
}

/// Creates a new AirshipEmbeddedView.
///
/// - Parameters:
/// - embeddedID: The embedded ID.
/// - size: The embedded size info. This is needed in a scroll view to determine proper percent based sizing.
/// - placeholder: The place holder block.
public init(
embeddedID: String,
embeddedSize: AirshipEmbeddedSize? = nil,
@ViewBuilder placeholder: @escaping () -> PlaceHolder = { EmptyView()}
) {
self.embeddedID = embeddedID
self.embeddedSize = embeddedSize
self.placeholder = placeholder
self._viewModel = StateObject(wrappedValue: EmbeddedViewModel(embeddedID: embeddedID))
}

/// Creates a new AirshipEmbeddedView.
///
/// - Parameters:
/// - embeddedID: The embedded ID.
/// - size: The embedded size info. This is needed in a scroll view to determine proper percent based sizing.
public init(
embeddedID: String,
embeddedSize: AirshipEmbeddedSize? = nil
) where PlaceHolder == EmptyView {
self.embeddedID = embeddedID
self.embeddedSize = embeddedSize
self.placeholder = { EmptyView() }
self._viewModel = StateObject(wrappedValue: EmbeddedViewModel(embeddedID: embeddedID))
}

public var body: some View {
Expand Down Expand Up @@ -82,10 +116,10 @@ private class EmbeddedViewModel: ObservableObject {
private var timer: AnyCancellable?
private var viewManager: AirshipEmbeddedViewManager

init(id: String, manager: AirshipEmbeddedViewManager = AirshipEmbeddedViewManager.shared) {
init(embeddedID: String, manager: AirshipEmbeddedViewManager = AirshipEmbeddedViewManager.shared) {
self.viewManager = manager
cancellable = viewManager
.publisher(embeddedViewID: id)
.publisher(embeddedViewID: embeddedID)
.receive(on: DispatchQueue.main)
.sink(receiveValue: onNewViewReceived)
}
Expand Down
2 changes: 1 addition & 1 deletion Airship/AirshipCore/Source/AirshipVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Foundation

public struct AirshipVersion {
public static let version = "18.0.0"
public static let version = "18.0.1"
public static func get() -> String {
return version
}
Expand Down
2 changes: 1 addition & 1 deletion AirshipContentExtension.podspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AIRSHIP_VERSION="18.0.0"
AIRSHIP_VERSION="18.0.1"

Pod::Spec.new do |s|
s.version = AIRSHIP_VERSION
Expand Down
2 changes: 1 addition & 1 deletion AirshipDebug.podspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AIRSHIP_VERSION="18.0.0"
AIRSHIP_VERSION="18.0.1"

Pod::Spec.new do |s|
s.version = AIRSHIP_VERSION
Expand Down
2 changes: 1 addition & 1 deletion AirshipServiceExtension.podspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AIRSHIP_VERSION="18.0.0"
AIRSHIP_VERSION="18.0.1"

Pod::Spec.new do |s|
s.version = AIRSHIP_VERSION
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@

[Migration Guides](https://github.com/urbanairship/ios-library/tree/main/Documentation/Migration)

## Version 18.0.1 March 22, 2024

Patch release that fixes a few regressions with 18.0.0.

### Changes
- Fixed issue with frequency checks being checked before the message is ready to display
- Fixed an issue with InApp potentially being blocked when upgrading from the prerelease version of 18.0.0 to the final version of 18.0.0


## Version 18.0.0 March 21, 2024

Major SDK release with several breaking changes. see the [Migration Guide](https://github.com/urbanairship/ios-library/tree/main/Documentation/Migration/migration-guide-17-18.md) for more info.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension EmbeddedViewMaker {
@ViewBuilder placeholder: @escaping () -> Content
) -> some View {
AirshipEmbeddedView(
id: isShowingPlaceholder ? "nonexistent view id" : id,
embeddedID: isShowingPlaceholder ? "nonexistent view id" : id,
embeddedSize: AirshipEmbeddedSize(maxWidth: maxWidth, maxHeight: maxHeight),
placeholder:placeholder
)
Expand Down
2 changes: 1 addition & 1 deletion Thomas/Thomas/EmbeddedView/HomeView23Grande.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct HomeView23Grande: View {
ScrollView(showsIndicators: false) {


AirshipEmbeddedView(id: "home_image")
AirshipEmbeddedView(embeddedID: "home_image")
.setAirshipEmbeddedStyle(DismissableStyle())


Expand Down

0 comments on commit 314551e

Please sign in to comment.