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

Push notifications are currently initializing

7 Answers 120 Views
Push Notifications
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Phil
Top achievements
Rank 1
Phil asked on 17 Feb 2015, 08:53 PM
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?

7 Answers, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 19 Feb 2015, 01:57 PM
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.
 
0
Aswin
Top achievements
Rank 1
answered on 01 Nov 2016, 04:00 AM

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));
    };
};

 

 

0
Martin
Telerik team
answered on 02 Nov 2016, 03:33 PM
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.
 
0
Aswin
Top achievements
Rank 1
answered on 11 Nov 2016, 05:52 AM

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.

 

0
Anton Dobrev
Telerik team
answered on 14 Nov 2016, 12:59 PM
@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.
 
0
Aswin
Top achievements
Rank 1
answered on 22 Nov 2016, 08:46 AM

@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
        }
    })();

0
Anton Dobrev
Telerik team
answered on 24 Nov 2016, 08:38 AM
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.
 
Tags
Push Notifications
Asked by
Phil
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Aswin
Top achievements
Rank 1
Martin
Telerik team
Share this question
or