Command palette

@yasinsensoy/native

React Native · APIs and utilities

Screen

Screen settings.

3 exports

Import

import { Screen, useKeepAwake, useCaptureProtection } from "@yasinsensoy/native";

Screen

module

Screen settings.

NameTypeDescription
keepAwake(tag?: string) => Promise<void>Prevents the screen from dimming. The tag keeps multiple callers from interfering: the screen may dim again once all tags are released.
allowSleep(tag?: string) => Promise<void>Releases a Screen.keepAwake tag.
isAwake() => booleanWhether any tag is keeping the screen awake.
getBrightness() => Promise<number>Brightness (0–1): the value set by the app or the system brightness.
setBrightness(value: number) => Promise<void>Changes the brightness (0–1), e.g. while showing a QR code/ticket. On Android only this app's window; on iOS it is system-wide, so it reverts when the app goes to the background and is reapplied when it returns.
resetBrightness() => Promise<void>Hands brightness back to the system.
setCaptureProtection(enabled: boolean) => Promise<void>Screenshot/recording protection (banking, payment screens). - Android: FLAG_SECURE; screenshots, recordings and the recent apps preview appear black. - iOS: using the secure layer the system uses for password fields, content appears blank in screenshots and recordings; in the app switcher it is hidden by a blurred overlay. Since Apple has no official API it may stop working in a future iOS version; you can still learn about screenshots via addScreenshotListener.
isCaptureProtected() => booleanWhether protection is on.
isCaptured() => Promise<boolean>iOS: whether the screen is being recorded or mirrored. Always false on Android.
addScreenshotListener(listener: () => void) => () => voidCalled when a screenshot is taken (iOS, Android 14+). Returns a function that ends the subscription.
addCaptureListener(listener: (event: { captured: boolean; }) => void) => () => voidCalled when screen recording starts/stops (iOS, Android 15+). Called once with the current state on subscribe.

useKeepAwake

function

Keeps the screen awake while the component is mounted (video, recipe, navigation screen). enabled: false releases it.

useKeepAwake(enabled?: boolean): void

Turns on screenshot/recording protection while the component is mounted (see Screen.setCaptureProtection).

useCaptureProtection(enabled?: boolean): void