Skip to content

Commit 914f5a1

Browse files
committed
Guarantee that messageView is a subview of OSInAppMessageVC
There is swiftUI crash where addConstraintsForMessage can be called without messageView being a subview of OSInAppMessageViewController's view. This is likely happening because viewWillTransitionToSize is being called before setupInitialMessageUI. Neither the crash reporters nor OneSignal have been able to reproduce the crash, but it is safe to always add messageView as a subview if it is not already.
1 parent 458eedb commit 914f5a1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

iOS_SDK/OneSignalSDK/Source/OSInAppMessageViewController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ Sets up the message view in its initial (hidden) position
280280
- (void)addConstraintsForMessage {
281281
[OneSignal onesignal_Log:ONE_S_LL_VERBOSE message:@"Setting up In-App Message Constraints"];
282282

283+
if (![self.view.subviews containsObject:self.messageView]) {
284+
[OneSignal onesignal_Log:ONE_S_LL_VERBOSE message:@"addConstraintsForMessage: messageView is not a subview of OSInAppMessageViewController"];
285+
[self.view addSubview:self.messageView];
286+
}
287+
283288
// Initialize the anchors that describe the edges of the view, such as the top, bottom, etc.
284289
NSLayoutAnchor *top = self.view.topAnchor,
285290
*bottom = self.view.bottomAnchor,

0 commit comments

Comments
 (0)