UNPKG

@b8safe/react-native-safe

Version:
34 lines (32 loc) 1.13 kB
"use strict"; import React, { createContext, useEffect, useRef } from 'react'; import { NativeModules, Platform } from 'react-native'; import { RTCConnectionInterface } from "../functions/RTCConnectionInterface.js"; import { jsx as _jsx } from "react/jsx-runtime"; export const B8SafeServiceContext = /*#__PURE__*/createContext(null); export const B8SafeProvider = ({ children, hashChecker, onReady }) => { // const [connected, setConnected] = useState(false); // const [localStream, setlocalStream] = useState<MediaStream>(); const rtcInstance = useRef(hashChecker != null ? new RTCConnectionInterface({ hashChecker }) : null); const servicesInitiator = async () => { if (Platform.OS === 'android') { await NativeModules.PlayIntegrity.prepareStandardIntegrityTokenProvider(null); } if (onReady != null) onReady(); }; useEffect(() => { servicesInitiator(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return /*#__PURE__*/_jsx(B8SafeServiceContext.Provider, { value: rtcInstance.current, children: children }); }; //# sourceMappingURL=B8Safe.js.map