INNER CODE UNIT · TypeScript
getOptedIn
OneSignal/react-native-onesignal · src/index.ts:367
export function getOptedIn(): boolean {
if (!isNativeModuleLoaded(RNOneSignal)) {
return false;
}
console.warn(
'OneSignal: This method has been deprecated. Use getOptedInAsync instead for getting push subscription opted in status.',
);
return pushSub.optedIn ?? false;
}
/**
* Gets a boolean value indicating whether the current user is opted in to push notifications.
* This returns true when the app has notifications permission and optOut is not called.
* Note: Does not take into account the existence of the subscription ID and push token.
* This boolean may return true but push notifications may still not be received by the user.
*/
export async function getOptedInAsync(): Promise<boolean> {