Error Registering Device for push notifications

Thread is closed for posting
4 posts, 1 answers
  1. Andrew
    Andrew avatar
    2 posts
    Member since:
    Sep 2016

    Posted 10 Nov 2016 Link to this post

    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;

     

  2. Answer
    Martin
    Admin
    Martin avatar
    104 posts

    Posted 10 Nov 2016 Link to this post

    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.

     
  3. Martin
    Admin
    Martin avatar
    104 posts

    Posted 11 Nov 2016 Link to this post

    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.

     
  4. Andrew
    Andrew avatar
    2 posts
    Member since:
    Sep 2016

    Posted 11 Nov 2016 in reply to Martin Link to this post

    Thanks very much
Back to Top