UNPKG

react-native-wear-connectivity

Version:
28 lines 1.22 kB
import { Platform } from 'react-native'; import { WearConnectivity } from './index'; import { LIBRARY_NAME, IOS_NOT_SUPPORTED_WARNING } from './constants'; const UNHANDLED_CALLBACK = 'The sendMessage function was called without a callback function. '; const UNHANDLED_CALLBACK_REPLY = 'The callback function was invoked with the payload: '; const UNHANDLED_CALLBACK_ERROR = 'The callback function was invoked with the error: '; const defaultReplyCb = reply => { console.log(UNHANDLED_CALLBACK + UNHANDLED_CALLBACK_REPLY, reply); }; const defaultErrCb = err => { console.warn(UNHANDLED_CALLBACK + UNHANDLED_CALLBACK_ERROR, err); }; const sendMessage = (message, cb, errCb) => { const json = { ...message, event: 'message' }; const callbackWithDefault = cb ?? defaultReplyCb; const errCbWithDefault = errCb ?? defaultErrCb; return WearConnectivity.sendMessage(json, callbackWithDefault, errCbWithDefault); }; const sendMessageMock = () => console.warn(LIBRARY_NAME + 'message' + IOS_NOT_SUPPORTED_WARNING); let sendMessageExport = sendMessageMock; if (Platform.OS !== 'ios') { sendMessageExport = sendMessage; } export { sendMessageExport as sendMessage }; //# sourceMappingURL=messages.js.map