react-native-guided-access-mode
v0.1.2
Published
accessibility features while using Guided Access
Downloads
57
Readme
react-native-guided-access-mode
accessibility features while using Guided Access
Installation
yarn add react-native-guided-access-mode
npx pod-install
Usage
import React, { useState, useEffect } from 'react';
import { View, Text } from 'react-native';
import {
isGuidedAccessEnabledAsync,
guidedAccessEventEmitter,
} from 'react-native-guided-access-mode';
const App = () => {
const [isGuidedAccessEnabled, setIsGuidedAccessEnabled] = useState(false);
useEffect(() => {
const checkGuidedAccessEnabled = async () => {
try {
const enabled = await isGuidedAccessEnabledAsync();
setIsGuidedAccessEnabled(enabled);
} catch (error) {
console.error('Failed to check Guided Access status:', error);
}
};
checkGuidedAccessEnabled();
const subscription = guidedAccessEventEmitter.addListener(
'guidedAccessStatusDidChange',
(event) => {
setIsGuidedAccessEnabled(event.enabled);
}
);
return () => {
subscription.remove();
};
}, []);
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>{`Guided Access is currently ${isGuidedAccessEnabled ? 'enabled' : 'disabled'}`}</Text>
</View>
);
};
export default App;
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library