This is a migrated thread and some comments may be shown as answers.

Error Registering Device for push notifications

3 Answers 49 Views
Report a bug
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andrew
Top achievements
Rank 1
Andrew asked on 10 Nov 2016, 09:26 AM

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;

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 10 Nov 2016, 09:58 AM

Hi David,

Indeed there is a bug with the latest JavaScript SDK (version 1.8.0) which was uploaded on 07.11.2016. We are working on solving the problem and a fix will be available in the next few days. I will notify you when this happens. Please accept our apologies for any inconvenience this might have caused.

Thank you for you detailed report - as a small token of gratitude we have updated your Telerik Points. You may also use the JavaScript SDK version 1.7.2 to fix the problem until we upload a new version.

Thank you for your understanding.

Regards,
Martin
Telerik by Progress
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Martin
Telerik team
answered on 11 Nov 2016, 09:28 AM
Hi David,

A new JavaScript SDK version 1.8.1 is now live and the problem is fixed.

Regards,
Martin
Telerik by Progress
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Andrew
Top achievements
Rank 1
answered on 11 Nov 2016, 09:40 AM
Thanks very much
Tags
Report a bug
Asked by
Andrew
Top achievements
Rank 1
Answers by
Martin
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or