diff --git a/BrazeKit.podspec b/BrazeKit.podspec index 8faec60902..eab1bd9628 100644 --- a/BrazeKit.podspec +++ b/BrazeKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'BrazeKit' - s.version = '10.2.0' + s.version = '10.3.0' s.summary = 'Braze Main SDK library providing support for analytics and push notifications.' s.homepage = 'https://braze.com' @@ -9,8 +9,8 @@ Pod::Spec.new do |s| s.authors = 'Braze, Inc.' s.source = { - :http => 'https://github.com/braze-inc/braze-swift-sdk/releases/download/10.2.0/BrazeKit.zip', - :sha256 => 'c0c593e68068edd1c8caa89ea4e18cdb6c0d52801c90c0b8a173dae3da757b9b' + :http => 'https://github.com/braze-inc/braze-swift-sdk/releases/download/10.3.0/BrazeKit.zip', + :sha256 => '4913d8c1ad1115ec50c07858523c6ba9ab506f37a39a853a4a19c77b82d7f821' } s.swift_version = '5.0' diff --git a/BrazeKitCompat.podspec b/BrazeKitCompat.podspec index 8477eb9781..1722769ffa 100644 --- a/BrazeKitCompat.podspec +++ b/BrazeKitCompat.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'BrazeKitCompat' - s.version = '10.2.0' + s.version = '10.3.0' s.summary = 'Compatibility library for users migrating from AppboyKit.' s.homepage = 'https://braze.com' @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.license = { :type => 'Commercial' } s.authors = 'Braze, Inc.' - s.source = { :git => 'https://github.com/braze-inc/braze-swift-sdk.git', :tag => '10.2.0' } + s.source = { :git => 'https://github.com/braze-inc/braze-swift-sdk.git', :tag => '10.3.0' } s.swift_version = '5.0' s.ios.deployment_target = '12.0' @@ -18,8 +18,8 @@ Pod::Spec.new do |s| s.public_header_files = 'Sources/BrazeKitCompat/include/*.h' s.static_framework = true - s.dependency 'BrazeKit', '10.2.0' - s.dependency 'BrazeLocation', '10.2.0' + s.dependency 'BrazeKit', '10.3.0' + s.dependency 'BrazeLocation', '10.3.0' s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } end diff --git a/BrazeLocation.podspec b/BrazeLocation.podspec index a041d632ae..1818866683 100644 --- a/BrazeLocation.podspec +++ b/BrazeLocation.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'BrazeLocation' - s.version = '10.2.0' + s.version = '10.3.0' s.summary = 'Braze location library providing support for location analytics and geofence monitoring.' s.homepage = 'https://braze.com' @@ -9,8 +9,8 @@ Pod::Spec.new do |s| s.authors = 'Braze, Inc.' s.source = { - :http => 'https://github.com/braze-inc/braze-swift-sdk/releases/download/10.2.0/BrazeLocation.zip', - :sha256 => '8ef04d2945942890bb8c8ff507ccfd76b1a7748274c3f37191381ee0fca398ab' + :http => 'https://github.com/braze-inc/braze-swift-sdk/releases/download/10.3.0/BrazeLocation.zip', + :sha256 => 'a0e299ea114723f5ae9e124a94c59304b082b838be422a4ae823384a713f563c' } s.swift_version = '5.0' @@ -21,7 +21,7 @@ Pod::Spec.new do |s| s.vendored_framework = 'BrazeLocation.xcframework' s.resource_bundles = { 'BrazeLocation' => ['Sources/BrazeLocationResources/Resources/**/*'] } - s.dependency 'BrazeKit', '10.2.0' + s.dependency 'BrazeKit', '10.3.0' s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } end diff --git a/BrazeNotificationService.podspec b/BrazeNotificationService.podspec index 52c9f0025c..98b3c0b138 100644 --- a/BrazeNotificationService.podspec +++ b/BrazeNotificationService.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'BrazeNotificationService' - s.version = '10.2.0' + s.version = '10.3.0' s.summary = 'Braze notification service extension library providing support for Rich Push notifications.' s.homepage = 'https://braze.com' @@ -9,8 +9,8 @@ Pod::Spec.new do |s| s.authors = 'Braze, Inc.' s.source = { - :http => 'https://github.com/braze-inc/braze-swift-sdk/releases/download/10.2.0/BrazeNotificationService.zip', - :sha256 => '3e8c00381f07545697f0a1f06198b7546800bc34bc0d0ea83ca3370b59de431d' + :http => 'https://github.com/braze-inc/braze-swift-sdk/releases/download/10.3.0/BrazeNotificationService.zip', + :sha256 => '4dbd229689d1d77a289ebbc60b5e7e367e2f5b2b1aff9a3c6539bceb6c21a51f' } s.swift_version = '5.0' diff --git a/BrazePushStory.podspec b/BrazePushStory.podspec index 1e545cc7b0..b151fa6d39 100644 --- a/BrazePushStory.podspec +++ b/BrazePushStory.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'BrazePushStory' - s.version = '10.2.0' + s.version = '10.3.0' s.summary = 'Braze notification content extension library providing support for Push Stories.' s.homepage = 'https://braze.com' @@ -9,8 +9,8 @@ Pod::Spec.new do |s| s.authors = 'Braze, Inc.' s.source = { - :http => 'https://github.com/braze-inc/braze-swift-sdk/releases/download/10.2.0/BrazePushStory.zip', - :sha256 => 'adb1fa1d70a52275f1e0ab9551f69fa7188bd997c7407202b89829c4423bc99b' + :http => 'https://github.com/braze-inc/braze-swift-sdk/releases/download/10.3.0/BrazePushStory.zip', + :sha256 => '1b0e1ecc6da91edb467dd0db3498fb09a89ddccf9ffbf5fc96479971499b5035' } s.swift_version = '5.0' diff --git a/BrazeUI.podspec b/BrazeUI.podspec index 60ddd94442..904eeb0fc3 100644 --- a/BrazeUI.podspec +++ b/BrazeUI.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'BrazeUI' - s.version = '10.2.0' + s.version = '10.3.0' s.summary = 'Braze-provided user interface library for In-App Messages and Content Cards.' s.homepage = 'https://braze.com' @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.license = { :type => 'Commercial' } s.authors = 'Braze, Inc.' - s.source = { :git => 'https://github.com/braze-inc/braze-swift-sdk.git', :tag => '10.2.0' } + s.source = { :git => 'https://github.com/braze-inc/braze-swift-sdk.git', :tag => '10.3.0' } s.swift_version = '5.0' s.ios.deployment_target = '12.0' @@ -18,7 +18,7 @@ Pod::Spec.new do |s| s.resource_bundles = { 'BrazeUI' => ['Sources/BrazeUI/Resources/**/*'] } s.static_framework = true - s.dependency 'BrazeKit', '10.2.0' + s.dependency 'BrazeKit', '10.3.0' s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } end diff --git a/BrazeUICompat.podspec b/BrazeUICompat.podspec index 613a1638a2..9f4548eccd 100644 --- a/BrazeUICompat.podspec +++ b/BrazeUICompat.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'BrazeUICompat' - s.version = '10.2.0' + s.version = '10.3.0' s.summary = 'Compatibility UI library for users migrating from AppboyUI.' s.homepage = 'https://braze.com' @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.license = { :type => 'Commercial' } s.authors = 'Braze, Inc.' - s.source = { :git => 'https://github.com/braze-inc/braze-swift-sdk.git', :tag => '10.2.0' } + s.source = { :git => 'https://github.com/braze-inc/braze-swift-sdk.git', :tag => '10.3.0' } s.swift_version = '5.0' s.ios.deployment_target = '12.0' @@ -18,7 +18,7 @@ Pod::Spec.new do |s| s.resource_bundles = { 'BrazeUICompat' => 'Sources/BrazeUICompat/*/Resources/**/*.*' } s.static_framework = true - s.dependency 'BrazeKitCompat', '10.2.0' + s.dependency 'BrazeKitCompat', '10.3.0' s.dependency 'SDWebImage', '>= 5.19.0', '< 6' s.user_target_xcconfig = { 'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES' } diff --git a/CHANGELOG.md b/CHANGELOG.md index c37f98477b..ab32b10e38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## 10.3.0 + +##### Fixed +- Fixes the in-app message orientation validation logic, which prevented certain device classes from displaying messages under certain orientation configurations. +- Fixes the default behavior on full-screen in-app messages to display as modals only on tablet screen sizes. + - Previously, full-screen messages would erroneously default to modal presentations on some larger phones. +- Fixes a crash when dismissing a slideup in-app message before it has finished presenting. +- Fixes an issue on iOS 18.0+ where the in-app message UI would persist on the screen when attempting to dismiss the message before it has finished presenting. +- Updates custom attribute value, custom event, and purchase string validation to use a 255 character maximum instead of a 255 byte maximum. + +##### Added +- The [`Braze.set(identifierForAdvertiser:)`](https://braze-inc.github.io/braze-swift-sdk/documentation/brazekit/braze/set(identifierforadvertiser:)) and [`Braze.set(identifierForVendor:)`](https://braze-inc.github.io/braze-swift-sdk/documentation/brazekit/braze/set(identifierforvendor:)) methods now accept a `nil` parameter value to remove the identifiers from the user profile. +- Adds additional safeguards to `Braze.Notifications.subscribeToUpdates` to ensure the same Push notification can't trigger the update closure multiple times. + ## 10.2.0 ##### Fixed diff --git a/Examples/ObjC/Examples-SwiftPM.xcodeproj/project.pbxproj b/Examples/ObjC/Examples-SwiftPM.xcodeproj/project.pbxproj index 879ce51e83..621626b802 100644 --- a/Examples/ObjC/Examples-SwiftPM.xcodeproj/project.pbxproj +++ b/Examples/ObjC/Examples-SwiftPM.xcodeproj/project.pbxproj @@ -963,7 +963,7 @@ mainGroup = D8CC2266D736859D7DD9A8FF; packageReferences = ( 9928D5150C45879A982BA1C6 /* XCRemoteSwiftPackageReference "SDWebImage" */, - 2770133CE94890188F3AFE6E /* XCLocalSwiftPackageReference "/Users/jacksonmiller/Documents/swift-sdk/.build/braze/release/braze-swift-sdk" */, + 6764A035A4A67CE751802C3E /* XCLocalSwiftPackageReference "/Users/louis.bur/Developer/swift-sdk/.build/braze/release/braze-swift-sdk" */, ); projectDirPath = ""; projectRoot = ""; @@ -2121,9 +2121,9 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCLocalSwiftPackageReference section */ - 2770133CE94890188F3AFE6E /* XCLocalSwiftPackageReference "/Users/jacksonmiller/Documents/swift-sdk/.build/braze/release/braze-swift-sdk" */ = { + 6764A035A4A67CE751802C3E /* XCLocalSwiftPackageReference "/Users/louis.bur/Developer/swift-sdk/.build/braze/release/braze-swift-sdk" */ = { isa = XCLocalSwiftPackageReference; - relativePath = "/Users/jacksonmiller/Documents/swift-sdk/.build/braze/release/braze-swift-sdk"; + relativePath = "/Users/louis.bur/Developer/swift-sdk/.build/braze/release/braze-swift-sdk"; }; /* End XCLocalSwiftPackageReference section */ diff --git a/Examples/ObjC/Sources/PushNotifications/Info.plist b/Examples/ObjC/Sources/PushNotifications/Info.plist deleted file mode 100644 index d7f8ec8ca2..0000000000 --- a/Examples/ObjC/Sources/PushNotifications/Info.plist +++ /dev/null @@ -1,30 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - PushNotifications - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - UIBackgroundModes - - remote-notification - - UILaunchStoryboardName - LaunchScreen - - diff --git a/Examples/ObjC/Sources/PushNotifications/PushNotifications.entitlements b/Examples/ObjC/Sources/PushNotifications/PushNotifications.entitlements deleted file mode 100644 index 9cad402b51..0000000000 --- a/Examples/ObjC/Sources/PushNotifications/PushNotifications.entitlements +++ /dev/null @@ -1,12 +0,0 @@ - - - - - aps-environment - development - com.apple.security.application-groups - - group.com.braze.PushNotifications.PushStories - - - diff --git a/Examples/ObjC/manual-integration-setup.sh b/Examples/ObjC/manual-integration-setup.sh index 9fd0bfe10e..ce42751e3e 100755 --- a/Examples/ObjC/manual-integration-setup.sh +++ b/Examples/ObjC/manual-integration-setup.sh @@ -20,7 +20,7 @@ if [ ! -f "manual-integration-setup.sh" ]; then fi # Constants -url="https://github.com/braze-inc/braze-swift-sdk/releases/download/10.2.0/braze-swift-sdk-prebuilt.zip" +url="https://github.com/braze-inc/braze-swift-sdk/releases/download/10.3.0/braze-swift-sdk-prebuilt.zip" echo "→" "Cleaning up" rm -rf braze-swift-sdk-prebuilt diff --git a/Examples/Swift/Examples-SwiftPM.xcodeproj/project.pbxproj b/Examples/Swift/Examples-SwiftPM.xcodeproj/project.pbxproj index df902a39d5..f9a5364db5 100644 --- a/Examples/Swift/Examples-SwiftPM.xcodeproj/project.pbxproj +++ b/Examples/Swift/Examples-SwiftPM.xcodeproj/project.pbxproj @@ -954,7 +954,7 @@ mainGroup = D8CC2266D736859D7DD9A8FF; packageReferences = ( 9928D5150C45879A982BA1C6 /* XCRemoteSwiftPackageReference "SDWebImage" */, - 2770133CE94890188F3AFE6E /* XCLocalSwiftPackageReference "/Users/jacksonmiller/Documents/swift-sdk/.build/braze/release/braze-swift-sdk" */, + 6764A035A4A67CE751802C3E /* XCLocalSwiftPackageReference "/Users/louis.bur/Developer/swift-sdk/.build/braze/release/braze-swift-sdk" */, ); projectDirPath = ""; projectRoot = ""; @@ -2109,9 +2109,9 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCLocalSwiftPackageReference section */ - 2770133CE94890188F3AFE6E /* XCLocalSwiftPackageReference "/Users/jacksonmiller/Documents/swift-sdk/.build/braze/release/braze-swift-sdk" */ = { + 6764A035A4A67CE751802C3E /* XCLocalSwiftPackageReference "/Users/louis.bur/Developer/swift-sdk/.build/braze/release/braze-swift-sdk" */ = { isa = XCLocalSwiftPackageReference; - relativePath = "/Users/jacksonmiller/Documents/swift-sdk/.build/braze/release/braze-swift-sdk"; + relativePath = "/Users/louis.bur/Developer/swift-sdk/.build/braze/release/braze-swift-sdk"; }; /* End XCLocalSwiftPackageReference section */ diff --git a/Examples/Swift/Sources/PushNotifications/Info.plist b/Examples/Swift/Sources/PushNotifications/Info.plist deleted file mode 100644 index d7f8ec8ca2..0000000000 --- a/Examples/Swift/Sources/PushNotifications/Info.plist +++ /dev/null @@ -1,30 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - PushNotifications - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - UIBackgroundModes - - remote-notification - - UILaunchStoryboardName - LaunchScreen - - diff --git a/Examples/Swift/Sources/PushNotifications/PushNotifications.entitlements b/Examples/Swift/Sources/PushNotifications/PushNotifications.entitlements deleted file mode 100644 index 9cad402b51..0000000000 --- a/Examples/Swift/Sources/PushNotifications/PushNotifications.entitlements +++ /dev/null @@ -1,12 +0,0 @@ - - - - - aps-environment - development - com.apple.security.application-groups - - group.com.braze.PushNotifications.PushStories - - - diff --git a/Examples/Swift/manual-integration-setup.sh b/Examples/Swift/manual-integration-setup.sh index 9fd0bfe10e..ce42751e3e 100755 --- a/Examples/Swift/manual-integration-setup.sh +++ b/Examples/Swift/manual-integration-setup.sh @@ -20,7 +20,7 @@ if [ ! -f "manual-integration-setup.sh" ]; then fi # Constants -url="https://github.com/braze-inc/braze-swift-sdk/releases/download/10.2.0/braze-swift-sdk-prebuilt.zip" +url="https://github.com/braze-inc/braze-swift-sdk/releases/download/10.3.0/braze-swift-sdk-prebuilt.zip" echo "→" "Cleaning up" rm -rf braze-swift-sdk-prebuilt diff --git a/Package.swift b/Package.swift index 298dc247e6..dfb87abc07 100644 --- a/Package.swift +++ b/Package.swift @@ -49,8 +49,8 @@ let package = Package( targets: [ .binaryTarget( name: "BrazeKit", - url: "https://github.com/braze-inc/braze-swift-sdk/releases/download/10.2.0/BrazeKit.zip", - checksum: "c0c593e68068edd1c8caa89ea4e18cdb6c0d52801c90c0b8a173dae3da757b9b" + url: "https://github.com/braze-inc/braze-swift-sdk/releases/download/10.3.0/BrazeKit.zip", + checksum: "4913d8c1ad1115ec50c07858523c6ba9ab506f37a39a853a4a19c77b82d7f821" ), .target( name: "BrazeKitResources", @@ -67,8 +67,8 @@ let package = Package( ), .binaryTarget( name: "BrazeLocation", - url: "https://github.com/braze-inc/braze-swift-sdk/releases/download/10.2.0/BrazeLocation.zip", - checksum: "8ef04d2945942890bb8c8ff507ccfd76b1a7748274c3f37191381ee0fca398ab" + url: "https://github.com/braze-inc/braze-swift-sdk/releases/download/10.3.0/BrazeLocation.zip", + checksum: "a0e299ea114723f5ae9e124a94c59304b082b838be422a4ae823384a713f563c" ), .target( name: "BrazeLocationResources", @@ -78,13 +78,13 @@ let package = Package( ), .binaryTarget( name: "BrazeNotificationService", - url: "https://github.com/braze-inc/braze-swift-sdk/releases/download/10.2.0/BrazeNotificationService.zip", - checksum: "3e8c00381f07545697f0a1f06198b7546800bc34bc0d0ea83ca3370b59de431d" + url: "https://github.com/braze-inc/braze-swift-sdk/releases/download/10.3.0/BrazeNotificationService.zip", + checksum: "4dbd229689d1d77a289ebbc60b5e7e367e2f5b2b1aff9a3c6539bceb6c21a51f" ), .binaryTarget( name: "BrazePushStory", - url: "https://github.com/braze-inc/braze-swift-sdk/releases/download/10.2.0/BrazePushStory.zip", - checksum: "adb1fa1d70a52275f1e0ab9551f69fa7188bd997c7407202b89829c4423bc99b" + url: "https://github.com/braze-inc/braze-swift-sdk/releases/download/10.3.0/BrazePushStory.zip", + checksum: "1b0e1ecc6da91edb467dd0db3498fb09a89ddccf9ffbf5fc96479971499b5035" ), .target( name: "BrazePushStoryResources", diff --git a/README.md b/README.md index b6d7fcc629..25f3278f0a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@

- Version: 10.2.0 + Version: 10.3.0 Void)? = nil) { - messageView?.dismiss(completion: completion) ?? completion?() + window?.messageViewController?.dismissMessage(completion: completion) ?? completion?() } // MARK: - Utils diff --git a/Sources/BrazeUI/InAppMessageUI/InAppMessageUIViewController.swift b/Sources/BrazeUI/InAppMessageUI/InAppMessageUIViewController.swift index 7e6d97e568..e9b7cbeb98 100644 --- a/Sources/BrazeUI/InAppMessageUI/InAppMessageUIViewController.swift +++ b/Sources/BrazeUI/InAppMessageUI/InAppMessageUIViewController.swift @@ -66,6 +66,9 @@ extension BrazeInAppMessageUI { /// If assigned, VoiceOver will focus on this element when the message view is presented. var messageViewInitialAccessibilityElement: Any? + /// Flag indicating whether the message is being dismissed or has already been dismissed. + var messageDismissed: Bool = false + // MARK: - Initialization /// Creates an in-app message view controller. @@ -121,10 +124,21 @@ extension BrazeInAppMessageUI { if presented { return } view.addSubview(messageView) - messageView.present(completion: nil) + messageView.present { + // If the message was dismissed while being presented, dismiss it again to ensure that + // cleanup occured properly. + if self.messageDismissed { + self.dismissMessage() + } + } presented = true } + open func dismissMessage(completion: (() -> Void)? = nil) { + messageDismissed = true + messageView.dismiss(completion: completion) + } + // MARK: - Orientation open override var supportedInterfaceOrientations: UIInterfaceOrientationMask { diff --git a/Sources/BrazeUI/InAppMessageUI/Views/InAppMessageUIFullImageView.swift b/Sources/BrazeUI/InAppMessageUI/Views/InAppMessageUIFullImageView.swift index cb87af4dff..600487c711 100644 --- a/Sources/BrazeUI/InAppMessageUI/Views/InAppMessageUIFullImageView.swift +++ b/Sources/BrazeUI/InAppMessageUI/Views/InAppMessageUIFullImageView.swift @@ -103,9 +103,8 @@ extension BrazeInAppMessageUI { } public lazy var displayMode: DisplayMode = - (traitCollection.horizontalSizeClass == .compact - ? .full - : .modal) + (traitCollection.horizontalSizeClass == .regular + && traitCollection.verticalSizeClass == .regular) ? .modal : .full { didSet { updateForDisplayMode() } } @@ -118,7 +117,9 @@ extension BrazeInAppMessageUI { open override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) if preferredDisplayMode == nil { - displayMode = traitCollection.horizontalSizeClass == .compact ? .full : .modal + displayMode = + (traitCollection.horizontalSizeClass == .regular + && traitCollection.verticalSizeClass == .regular) ? .modal : .full } } #endif diff --git a/Sources/BrazeUI/InAppMessageUI/Views/InAppMessageUIFullView.swift b/Sources/BrazeUI/InAppMessageUI/Views/InAppMessageUIFullView.swift index 83fab9310a..28549556f3 100644 --- a/Sources/BrazeUI/InAppMessageUI/Views/InAppMessageUIFullView.swift +++ b/Sources/BrazeUI/InAppMessageUI/Views/InAppMessageUIFullView.swift @@ -110,9 +110,8 @@ extension BrazeInAppMessageUI { } public lazy var displayMode: DisplayMode = - (traitCollection.horizontalSizeClass == .compact - ? .full - : .modal) + (traitCollection.horizontalSizeClass == .regular + && traitCollection.verticalSizeClass == .regular) ? .modal : .full { didSet { updateForDisplayMode() } } @@ -140,7 +139,9 @@ extension BrazeInAppMessageUI { open override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) if preferredDisplayMode == nil { - displayMode = traitCollection.horizontalSizeClass == .compact ? .full : .modal + displayMode = + (traitCollection.horizontalSizeClass == .regular + && traitCollection.verticalSizeClass == .regular) ? .modal : .full } } #endif diff --git a/Sources/BrazeUI/InAppMessageUI/Views/InAppMessageUISlideupView.swift b/Sources/BrazeUI/InAppMessageUI/Views/InAppMessageUISlideupView.swift index 82d5ce02ff..6a91d12005 100644 --- a/Sources/BrazeUI/InAppMessageUI/Views/InAppMessageUISlideupView.swift +++ b/Sources/BrazeUI/InAppMessageUI/Views/InAppMessageUISlideupView.swift @@ -413,6 +413,10 @@ extension BrazeInAppMessageUI { open var presented: Bool = false { didSet { + // It is technically possible to dismiss the slideup before it has been presented. In that + // case, the presentation constraints are not yet initialized and we guard against their + // installation to prevent a potential crash. + guard presentationConstraintsInstalled else { return } presented ? NSLayoutConstraint.activate([innerYConstraint, outerYConstraint]) : NSLayoutConstraint.deactivate([innerYConstraint, outerYConstraint]) @@ -496,7 +500,9 @@ extension BrazeInAppMessageUI { @objc func pan(_ gesture: UIPanGestureRecognizer) { - guard let superview = gesture.view?.superview else { return } + guard let superview = gesture.view?.superview, presentationConstraintsInstalled else { + return + } let dismissible = attributes.dismissible var dy = gesture.translation(in: superview).y