wonday / react-native-orientation-locker

A react-native module that can listen on orientation changing of device, get current orientation, lock to preferred orientation.
MIT License
761 stars 274 forks source link

fix: properly get window scene to avoid crash on CarPlay app #298

Closed ouabing closed 5 months ago

ouabing commented 5 months ago

This PR is aimed to solve the issue that app crashes if it's opened from iOS CarPlay. When invoking lockToXXX functions, lockToOrientation will try to get the first scene from the connectedScenes, if the app is opened from CarPlay, the first scene will be a CPTemplateApplicationScene instance, which causes the crash below.

NSInvalidArgumentException
-[CPTemplateApplicationScene requestGeometryUpdateWithPreferences:errorHandler:]: unrecognized selector sent to instance 0x122b1aca0

react-native-screens has a similar issue which got solved by this PR