Push notifications are currently initializing

8 posts, 0 answers
  1. Phil
    Phil avatar
    15 posts
    Member since:
    Oct 2012

    Posted 17 Feb 2015 Link to this post

    I deployed my application to a second testing device and am having trouble registering for push notifications. The error message I'm receiving back is "Push notifications are currently initializing." No matter how many times I attempt the registration, I get the same error message.

    Google didn't turn up anything for that error message.

    Any ideas?
  2. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 19 Feb 2015 Link to this post

    Hi Phil,

    This error is emitted from the Backend Services JS SDK and means that the initial call to el.push.register() method has not yet finished, but it was called again by the app.

    Could you please specify the following:
    • Device OS
    • Backend Services JavaScript SDK version
    • Push Plugin version
    • Any steps to reproduce the issue.

    If it is more convenient for you, please, attach a sample project in this thread. Please omit any API keys and project numbers from it before attaching it.

    I look forward to your reply.

    Best regards,
    Anton Dobrev
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  3. Aswin
    Aswin avatar
    6 posts
    Member since:
    Oct 2016

    Posted 31 Oct Link to this post

    I am also trying to implement push notification for my hybrid application using telerik platform. It is working fine for iOS. But in android, its getting an error Push notifications are currently initializing. This is the code that i have used.Its going to errorCallback. Could any one please help me out with this? Thanks in advance.

    app.everlive = new Everlive({
        appId: "xxxxxxx",
        scheme: 'http'
    });
    var enablePushNotifications = function() {
        var devicePushSettings = {
            iOS: {
                badge: 'true',
                sound: 'true',
                alert: 'true'
            },
            android: {
                senderID: 'xxxxxxx'
            },
            wp8: {
                channelName: 'EverlivePushChannel'
            },
            notificationCallbackIOS: onPushNotificationReceived,
            notificationCallbackAndroid: onPushNotificationReceived,
            notificationCallbackWP8: onPushNotificationReceived
        };
        app.everlive.push.currentDevice().enableNotifications(devicePushSettings, successCallback, errorCallback);
        //setTimeout(successCallback, 2000);
        function onPushNotificationReceived(e) {
            alert(JSON.stringify(e));
        };

        function successCallback(e) {
            app.everlive.push.register(devicePushSettings, function() {
                alert("Successful registration in Backend Services. You are ready to receive push notifications.");
            }, function(err) {
                alert("Error: " + err.message);
            });
            alert(JSON.stringify(e));
        };

        function errorCallback(e) {
            alert(JSON.stringify(e));
        };
    };

     

     

  4. Martin
    Admin
    Martin avatar
    67 posts

    Posted 02 Nov Link to this post

    Hi Aswin,

    Please use the described push registration method here without calling push.currentDevice().enableNotifications()  - the push.registration() method is calling these methods internally.

    Also you may review our Push Notification Sample App for sample implementation.

    Let me know if you need further information.

    Regards,
    Martin
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  5. Aswin
    Aswin avatar
    6 posts
    Member since:
    Oct 2016

    Posted 10 Nov in reply to Martin Link to this post

    Thanks for the reply Martin. I have used the register method as you mentioned. Still getting the error. First time when I am trying to register,

    javascript:Everlive.PushCallbacks.gcmCallback_Fri Nov 11 2016 11:10:45 GMT+0530 (IST)({"event":"registered","regid":"xxxxxxx"}).

    Second time when I am trying to register without killing the application, Its going to error call back with  an error"Push notifications are currently initializing". Can you please help me out with this issue.

     

  6. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 14 Nov Link to this post

    @Aswin

    This error signifies that the whole registration process did not succeed yet, that is why you cannot call register again before the previous call finishes (hence the error).

    Can you please share your code that reproduces the issue?

    Regards,
    Anton Dobrev
    Telerik by Progress
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  7. Aswin
    Aswin avatar
    6 posts
    Member since:
    Oct 2016

    Posted 22 Nov Link to this post

    @anton  Thanks for the reply. Please find the code.

     

    app.everlive = new Everlive({
                    appId: "xxxxxxxxx",
                    scheme: 'http'
    });

    app.PushRegistrar = (function () {
            var _onDeviceIsSuccessfullyInitialized = function () {
                console.log("The device is succcessfully initialized for push notifications.");
                console.log("Push token received!");
                console.log("Verifying device registration...");
            };
            var _onDeviceIsSuccessfullyRegistered = function () {
                console.log("Your device is successfully registered in Backend Services.");
                console.log("You can receive push notifications.");
            };

            var _onDeviceIsAlreadyRegistered = function () {
                console.log("Your device is already registered in Telerik Backend Services.");
                console.log("Updating the device registration...");
            };

            var _onDeviceIsNotRegistered = function () {
                console.log("Your device is not registered in Backend Services.");
                console.log("Registering the device in Backend Services...");
            };

            var _onDeviceRegistrationUpdated = function () {
                console.log("Successfully updated the device registration.");
            };

            var _onPushErrorOccurred = function (message) {
                console.log("Error: " + message, true);
            };

            var _processPushMessage = function (message, date) {
                console.log(date + " : " + message);
            };

            var onAndroidPushReceived = function (e) {
                var message = e.message;
                console.info("message",e.message);
                var dateCreated = app.formatDate(e.payload.customData.dateCreated);

                _processPushMessage(message, dateCreated);
            };

            var onWpPushReceived = function (e) {
                if (e.type === "toast" && e.jsonContent) {
                    var message = e.jsonContent["wp:Text2"];
                    _processPushMessage(message, new Date());
                }
            };

            var onIosPushReceived = function (e) {
                var message = e.alert;
                var dateCreated = app.formatDate(e.dateCreated);

                _processPushMessage(message, dateCreated);
            };

            var pushSettings = {
                android: {
                    senderID: xxxxxxxx
                    //projectNumber: app.androidProjectNumber

                },
                iOS: {
                    badge: "true",
                    sound: "true",
                    alert: "true"
                },
                wp8: {
                    channelName: "EverlivePushChannel"
                },
                notificationCallbackWP8: onWpPushReceived,
                notificationCallbackAndroid: onAndroidPushReceived,
                notificationCallbackIOS: onIosPushReceived
            };
            var enablePushNotifications = function () {
                $.currentDevice = device.uuid;
                var devicePlatform = device.platform; // get the device platform from the Cordova Device API
                console.log("Initializing push notifications for " + devicePlatform + '...');

                $.actualcurrentDevice = app.everlive.push.currentDevice(app.constants.EMULATOR_MODE);

                var customDeviceParameters = {
                    "LastLoginDate": new Date()
                };

                $.actualcurrentDevice.enableNotifications(pushSettings).then(
                        function (initResult) {
                            _onDeviceIsSuccessfullyInitialized();

                            return $.actualcurrentDevice.getRegistration();
                        },
                        function (err) {
                            _onPushErrorOccurred(err.message);
                        }).then(
                            function (registration) {
                                _onDeviceIsAlreadyRegistered();

                                $.actualcurrentDevice
                                    .updateRegistration(customDeviceParameters).then(function () {
                                        _onDeviceRegistrationUpdated();
                                    }, function (err) {
                                        _onPushErrorOccurred(err.message);
                                    });
                            },
                            function (err) {
                                if (err.code === 801) {
                                    _onDeviceIsNotRegistered();

                                    $.actualcurrentDevice.register(customDeviceParameters)
                                        .then(function (regData) {
                                            _onDeviceIsSuccessfullyRegistered();
                                        }, function (err) {
                                            _onPushErrorOccurred(err.message);
                                        });
                                }
                                else {
                                    _onPushErrorOccurred(err.message);
                                }
                            }
                            );
            };
            return {
                enablePushNotifications: enablePushNotifications
            }
        })();

  8. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 24 Nov Link to this post

    Hello Aswin,

    I tested the code you provided in the "Advanced" sample and it worked as expected.

    Can you please verify that you are:

    - Supplying a correct sender ID obtained from Firebase
    - Deploying the app as an actual package on an Android device

    Here is the code I used (with tiny modifications) based on yours:
    (function (global) {
        app.everlive = new Everlive({
                    appId: "xxxxxxxxxxxxxxx",
                    scheme: 'http'
    });
     
    app.PushRegistrar = (function () {
            var _onDeviceIsSuccessfullyInitialized = function () {
                alert("The device is succcessfully initialized for push notifications.");
                alert("Push token received!");
                alert("Verifying device registration...");
            };
            var _onDeviceIsSuccessfullyRegistered = function () {
                alert("Your device is successfully registered in Backend Services.");
                alert("You can receive push notifications.");
            };
     
            var _onDeviceIsAlreadyRegistered = function () {
                alert("Your device is already registered in Telerik Backend Services.");
                alert("Updating the device registration...");
            };
     
            var _onDeviceIsNotRegistered = function () {
                alert("Your device is not registered in Backend Services.");
                alert("Registering the device in Backend Services...");
            };
     
            var _onDeviceRegistrationUpdated = function () {
                alert("Successfully updated the device registration.");
            };
     
            var _onPushErrorOccurred = function (message) {
                alert("Error: " + message, true);
            };
     
            var _processPushMessage = function (message, date) {
                alert(date + " : " + message);
            };
     
            var onAndroidPushReceived = function (e) {
                var message = e.message;
                console.info("message",e.message);
                var dateCreated = app.formatDate(e.payload.customData.dateCreated);
     
                _processPushMessage(message, dateCreated);
            };
     
            var onWpPushReceived = function (e) {
                if (e.type === "toast" && e.jsonContent) {
                    var message = e.jsonContent["wp:Text2"];
                    _processPushMessage(message, new Date());
                }
            };
     
            var onIosPushReceived = function (e) {
                var message = e.alert;
                var dateCreated = app.formatDate(e.dateCreated);
     
                _processPushMessage(message, dateCreated);
            };
     
            var pushSettings = {
                android: {
                    senderID: 'xxxxxxxxxxxx'
                    //projectNumber: app.androidProjectNumber
     
                },
                iOS: {
                    badge: "true",
                    sound: "true",
                    alert: "true"
                },
                wp8: {
                    channelName: "EverlivePushChannel"
                },
                notificationCallbackWP8: onWpPushReceived,
                notificationCallbackAndroid: onAndroidPushReceived,
                notificationCallbackIOS: onIosPushReceived
            };
            var enablePushNotifications = function () {
                $.currentDevice = device.uuid;
                var devicePlatform = device.platform; // get the device platform from the Cordova Device API
                alert("Initializing push notifications for " + devicePlatform + '...');
     
                $.actualcurrentDevice = app.everlive.push.currentDevice();
     
                var customDeviceParameters = {
                    "LastLoginDate": new Date()
                };
     
                $.actualcurrentDevice.enableNotifications(pushSettings).then(
                        function (initResult) {
                            _onDeviceIsSuccessfullyInitialized();
     
                            return $.actualcurrentDevice.getRegistration();
                        },
                        function (err) {
                            _onPushErrorOccurred(err.message);
                        }).then(
                            function (registration) {
                                _onDeviceIsAlreadyRegistered();
     
                                $.actualcurrentDevice
                                    .updateRegistration(customDeviceParameters).then(function () {
                                        _onDeviceRegistrationUpdated();
                                    }, function (err) {
                                        _onPushErrorOccurred(err.message);
                                    });
                            },
                            function (err) {
                                if (err.code === 801) {
                                    _onDeviceIsNotRegistered();
     
                                    $.actualcurrentDevice.register(customDeviceParameters)
                                        .then(function (regData) {
                                            _onDeviceIsSuccessfullyRegistered();
                                        }, function (err) {
                                            _onPushErrorOccurred(err.message);
                                        });
                                }
                                else {
                                    _onPushErrorOccurred(err.message);
                                }
                            }
                            );
            };
            return {
                enablePushNotifications: enablePushNotifications
            }
        })();
    })(window);


    Regards,
    Anton Dobrev
    Telerik by Progress
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
Back to Top