react-native-wear-connectivity
Version:
Enstablish a two-way connection with wearOS
33 lines (32 loc) • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.sendMessage = void 0;
var _reactNative = require("react-native");
var _index = require("./index");
var _constants = require("./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 _index.WearConnectivity.sendMessage(json, callbackWithDefault, errCbWithDefault);
};
const sendMessageMock = () => console.warn(_constants.LIBRARY_NAME + 'message' + _constants.IOS_NOT_SUPPORTED_WARNING);
let sendMessageExport = exports.sendMessage = sendMessageMock;
if (_reactNative.Platform.OS !== 'ios') {
exports.sendMessage = sendMessageExport = sendMessage;
}
//# sourceMappingURL=messages.js.map