@@ -420,6 +420,7 @@ - (UIView *)sceneView {
420420// Each side uses the larger of the margin and its safe area inset, and on iOS 27.1+ keeps the margin
421421// from hardware inside a side safe area (e.g. a foldable's camera), matching system notification banners.
422422// Regions flush with the edge, like a status bar column, are already covered by the safe area.
423+ // Region frames already include UIKit's interactive margins; the message margin is added on top.
423424- (UIEdgeInsets)horizontalInsets {
424425 UIView *sceneView = [self sceneView ];
425426 CGFloat margin = self.useWidthMargin ? [OneSignalCoreHelper sizeToScale: MESSAGE_MARGIN ] : 0 ;
@@ -451,6 +452,7 @@ - (void)updateHorizontalInsets {
451452 return ;
452453 }
453454 UIEdgeInsets insets = [self horizontalInsets ];
455+ self.messageView .horizontalInsets = insets;
454456 // Only assign changes, since this runs on every layout pass
455457 if (self.leftConstraint .constant != insets.left ) {
456458 self.leftConstraint .constant = insets.left ;
@@ -505,6 +507,11 @@ - (void)addConstraintsForMessage {
505507 [OneSignalLog onesignalLog: ONE_S_LL_VERBOSE message: screenScale];
506508 let heightMessage = [NSString stringWithFormat: @" In App Message Height: %f " , self .message.height.doubleValue];
507509 [OneSignalLog onesignalLog: ONE_S_LL_VERBOSE message: heightMessage];
510+ UIView *sceneView = [self sceneView ];
511+ let layoutMessage = [NSString stringWithFormat: @" In App Message layout: scene view %@ (level %.0f ) bounds %@ safe area %@ horizontal insets %@ " ,
512+ NSStringFromClass (sceneView.class), sceneView.window.windowLevel, NSStringFromCGRect(sceneView.bounds),
513+ NSStringFromUIEdgeInsets (sceneView.safeAreaInsets), NSStringFromUIEdgeInsets([self horizontalInsets ])];
514+ [OneSignalLog onesignalLog: ONE_S_LL_VERBOSE message: layoutMessage];
508515
509516 // Height constraint based on the IAM being full screen or any others with a specific height
510517 // NOTE: full screen IAM payload has no height, so match screen height minus margins
@@ -984,8 +991,10 @@ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIV
984991 [self .messageView resetWebViewToMaxBoundsAndResizeHeight: ^(NSNumber *newHeight) {
985992 [OneSignalLog onesignalLog: ONE_S_LL_VERBOSE message: @" Orientation Change Complete with New Height: Adding constraints again and showing IAM" ];
986993
987- // Assign new height to message
988- self.message .height = newHeight;
994+ // Keep the previous height if JS couldn't measure the page
995+ if (newHeight) {
996+ self.message .height = newHeight;
997+ }
989998
990999 // Add all of the constraints using the new message height obtained from JS code
9911000 [self addConstraintsForMessage ];
0 commit comments