Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device orientation returns 0/Unknown on init #317

Open
brianrclow opened this issue Jan 6, 2023 · 0 comments
Open

Device orientation returns 0/Unknown on init #317

brianrclow opened this issue Jan 6, 2023 · 0 comments

Comments

@brianrclow
Copy link

brianrclow commented Jan 6, 2023

File in question: xplat/nativescript/core/src/lib/services/app.service.ts

This App Service gets the orientation on initialization and can be used for when the orientation changes. The getOrientation() function returns an empty string when it can't match landscape or portrait for UIDevice.currentDevice.orientation

At first I thought this was an issue with not being able to get the orientation on a simulator but I also tried on a few devices and got the same results. The service couldn't get the orientation so it defaulted to 0 which is Unknown, in this case it defaults to portrait.

let orientation = getOrientation();
this.orientation = orientation ? orientation : CoreTypes.DeviceOrientation.portrait;

This normally isn't an issue as many apps are portrait by default but for an app that needs to open in landscape and support landscape features properly, it doesn't quite work. The service does get landscape as the orientation but only after going from landscape (on open), to portrait then back to landscape.

I'm curious if this is a limitation of when this service gets initialized in the app lifecycle or if this is something that can be updated/improved, how that process would work?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant