UNPKG

react-native-wifi-connect

Version:
79 lines (73 loc) 2.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.connect = connect; exports.getSSID = getSSID; exports.isWifiOn = isWifiOn; exports.startHS = startHS; exports.stopHS = stopHS; exports.wifiSwitch = wifiSwitch; var _reactNative = require("react-native"); const LINKING_ERROR = `The package 'react-native-wifi-connect' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n'; const WifiConnect = _reactNative.NativeModules.WifiConnect ? _reactNative.NativeModules.WifiConnect : new Proxy({}, { get() { throw new Error(LINKING_ERROR); } }); const LocalOnlyHotspot = _reactNative.NativeModules.LocalOnlyHotspot ? _reactNative.NativeModules.LocalOnlyHotspot : new Proxy({}, { get() { throw new Error(LINKING_ERROR); } }); // Android Only function startHS() { if (_reactNative.Platform.OS === 'android') { return LocalOnlyHotspot.start(); } else if (_reactNative.Platform.OS === 'ios') { return Promise.resolve('Not Built for iOS'); } } // Android Only function stopHS() { if (_reactNative.Platform.OS === 'android') { return LocalOnlyHotspot.stop(); } else if (_reactNative.Platform.OS === 'ios') { return Promise.resolve('Not Built for iOS'); } } function connect(ssid, pass) { if (_reactNative.Platform.OS === 'android') { return WifiConnect.connect(ssid, pass); } else if (_reactNative.Platform.OS === 'ios') { return Promise.resolve('Not Built for iOS'); } } // Android Only function wifiSwitch() { if (_reactNative.Platform.OS === 'android') { WifiConnect.switch(); } else if (_reactNative.Platform.OS === 'ios') { console.log('Not Built for iOS'); } } // Android Only function getSSID() { if (_reactNative.Platform.OS === 'android') { return WifiConnect.getSSID(); } else if (_reactNative.Platform.OS === 'ios') { return Promise.resolve('Not Built for iOS'); } } // Android Only function isWifiOn() { if (_reactNative.Platform.OS === 'android') { return WifiConnect.isOn(); } else if (_reactNative.Platform.OS === 'ios') { return Promise.resolve('Not Built for iOS'); } } //# sourceMappingURL=index.js.map