Skip to content

Commit dfd0650

Browse files
committed
Manually controlling supportedInterfaceOrientations for IAMs
1 parent 6f8eab7 commit dfd0650

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

iOS_SDK/OneSignalSDK/Source/OSInAppMessageViewController.m

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,40 @@ - (void)jsEventOccurredWithBody:(NSData *)body {
655655
}
656656
}
657657

658+
/*
659+
Unity overrides orientation behavior and enables all orientations in supportedInterfaceOrientations, regardless of
660+
the values set in the info.plist. It then uses its own internal logic for restricting the Application's views to
661+
the selected orientations. This view controller inherits the behavior of all orientations being allowed so we need
662+
to manually set the supported orientations based on the values in the plist.
663+
If no values are selected for the orientation key in the plist then we will default to super's behavior.
664+
*/
665+
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
666+
NSUInteger orientationMask = 0;
667+
NSArray *supportedOrientations = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UISupportedInterfaceOrientations"];
668+
if (!supportedOrientations) {
669+
return [super supportedInterfaceOrientations];
670+
}
671+
672+
if ([supportedOrientations containsObject:@"UIInterfaceOrientationLandscapeLeft"]) {
673+
orientationMask += UIInterfaceOrientationMaskLandscapeLeft;
674+
}
675+
676+
if ([supportedOrientations containsObject:@"UIInterfaceOrientationLandscapeRight"]) {
677+
orientationMask += UIInterfaceOrientationMaskLandscapeRight;
678+
}
679+
680+
if ([supportedOrientations containsObject:@"UIInterfaceOrientationPortrait"]) {
681+
orientationMask += UIInterfaceOrientationMaskPortrait;
682+
}
683+
684+
if ([supportedOrientations containsObject:@"UIInterfaceOrientationPortraitUpsideDown"]) {
685+
orientationMask += UIInterfaceOrientationMaskPortraitUpsideDown;
686+
}
687+
688+
return orientationMask;
689+
690+
}
691+
658692
/*
659693
Override method for handling orientation change within a view controller on iOS 8 or higher
660694
This specifically handles the resizing and reanimation of a currently showing IAM

0 commit comments

Comments
 (0)