UNPKG

react-native-smartconfig-tem

Version:
61 lines (47 loc) 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _reactNative = require("react-native"); let { SmartconfigSwjava } = _reactNative.NativeModules; const eventEmitter = new _reactNative.NativeEventEmitter(SmartconfigSwjava); var subscription; const startSmartConfig = (ssid, bssid, password, timeScan, callback) => { let eventNameToListener = 'SmartConfig'; if (_reactNative.Platform.OS == 'ios') { console.log('[SMARTCONFIG] start ios config'); if (typeof subscription !== 'undefined' && subscription) { console.log('[SMARTCONFIG] remove listener'); subscription.remove(); } subscription = eventEmitter.addListener(eventNameToListener, callback); SmartconfigSwjava.start(ssid, bssid, password, timeScan, callback); } else { console.log('[SMARTCONFIG] start android config'); let taskCount = 1; // only find 1 device if (typeof subscription !== 'undefined' && subscription) { console.log('[SMARTCONFIG] remove listener'); subscription.remove(); } subscription = _reactNative.DeviceEventEmitter.addListener(eventNameToListener, callback); SmartconfigSwjava.start(ssid, bssid, password, timeScan, taskCount); } }; const stopSmartConfig = () => { console.log('[SMARTCONFIG] Stop config'); SmartconfigSwjava.stop(); }; class SmartConfig { static start(ssid, bssid, password, timeScan, callback) { startSmartConfig(ssid, bssid, password, timeScan, callback); } static stop() { stopSmartConfig(); } } var _default = SmartConfig; exports.default = _default; //# sourceMappingURL=index.js.map