I came across this error whilst registering a device for push notifications:
CordovaCurrentDevice.ensurePushIsAvailable is not a function
stack trace:
everlive.all.js:17898 Uncaught TypeError: CordovaCurrentDevice.ensurePushIsAvailable is not a function(…)ensurePushIsAvailable @ everlive.all.js:17898Push.ensurePushIsAvailable @ everlive.all.js:12066Push.register @ everlive.all.js:12138(anonymous function) @ index.js:150(anonymous function) @ index.js:121(anonymous function) @ index.js:105i @ jquery.min.js:3handlers.(anonymous function) @ kendo.all.min.js:29trigger @ kendo.all.min.js:25complete @ kendo.all.min.js:109complete @ kendo.all.min.js:29i @ jquery.min.js:3(anonymous function) @ jquery.min.js:3c @ jquery.min.js:3fireWith @ jquery.min.js:3i.(anonymous function) @ jquery.min.js:3c @ kendo.all.min.js:29i @ jquery.min.js:4dispatch @ jquery.min.js:3v.handle @ jquery.min.js:3
The issues lies in this section of code between lines 17871 and 17901 from the everlive.all.js file that I got following this documentation : http://docs.telerik.com/platform/backend-services/javascript/push-notifications/push-getting-started#initialize-and-register-the-device-for-push-notifications
/***/ },
/* 65 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var platform = __webpack_require__(5);
function getCurrentDevice(pushHandler) {
if (platform.isNativeScript) {
var NativeScriptCurrentDevice = __webpack_require__(32);
return new NativeScriptCurrentDevice(pushHandler);
}
else if (platform.isCordova || platform.isDesktop) {
var CordovaCurrentDevice = __webpack_require__(31);
return new CordovaCurrentDevice(pushHandler);
}
else {
return {};
}
}
exports.getCurrentDevice = getCurrentDevice;
function ensurePushIsAvailable() {
if (platform.isNativeScript) {
var NativeScriptCurrentDevice = __webpack_require__(32);
NativeScriptCurrentDevice.ensurePushIsAvailable();
}
else if (platform.isCordova || platform.isDesktop) {
var CordovaCurrentDevice = __webpack_require__(31);
CordovaCurrentDevice.ensurePushIsAvailable();
}
}
exports.ensurePushIsAvailable = ensurePushIsAvailable;
The functions are expecting CordovaCurrentDevice to be the constructor and to have the method ensurePushIsAvailable, however it appears these are in a variable called .CurrentDevice. Changing the getCurrentDevice and ensurePushIsAvailable functions so that they use CordovaCurrentDevice.CurrentDevice appears to have fixed the issue for me. Note, I'm using cordova and not nativescript but i'd guess that might have the same issue.
Bellow is the code amended to work for me.
/***/ },
/* 65 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
var platform = __webpack_require__(5);
function getCurrentDevice(pushHandler) {
if (platform.isNativeScript) {
var NativeScriptCurrentDevice = __webpack_require__(32);
return new NativeScriptCurrentDevice(pushHandler);
}
else if (platform.isCordova || platform.isDesktop) {
var CordovaCurrentDevice = __webpack_require__(31);
return new CordovaCurrentDevice.CurrentDevice(pushHandler);
}
else {
return {};
}
}
exports.getCurrentDevice = getCurrentDevice;
function ensurePushIsAvailable() {
if (platform.isNativeScript) {
var NativeScriptCurrentDevice = __webpack_require__(32);
NativeScriptCurrentDevice.ensurePushIsAvailable();
}
else if (platform.isCordova || platform.isDesktop) {
var CordovaCurrentDevice = __webpack_require__(31);
CordovaCurrentDevice.CurrentDevice.ensurePushIsAvailable();
}
}
exports.ensurePushIsAvailable = ensurePushIsAvailable;