Push notification not working in Android platform

I have created the push notification for Android, but its not working. Even I did not get register id back while I registered. Here is my code. please help me what mistake I did in the code.

// Register
$scope.register = function () {
var config = null;

    if (ionic.Platform.isAndroid()) {
        config = {
            "senderID": "xxxxxxx45" 
    else if (ionic.Platform.isIOS()) {
        config = {
            "badge": "true",
            "sound": "true",
            "alert": "true"

    $cordovaPush.register(config).then(function (result) {
        console.log("Register success " + result);  // I can see "OK" msg in the result variable, not reg id 

        $cordovaToast.showShortCenter('Registered for push notifications..'+result);
        if (ionic.Platform.isIOS()) {
            $scope.regId = result;
    }, function (err) {
        console.log("Register error " + err)
		$cordovaToast.showShortCenter('Registration failure..'+err);

// Notification Received
$scope.$on('$cordovaPush:notificationReceived', function (event, notification) {
    if (ionic.Platform.isAndroid()) {
    else if (ionic.Platform.isIOS()) {
        $scope.$apply(function () {

// Android Notification Received Handler
function handleAndroid(notification) {
    console.log("In foreground " + notification.foreground  + " Coldstart " + notification.coldstart);
	$cordovaDialogs.alert("received: "+notification);
    if (notification.event == "registered") {
        $scope.regId = notification.regid;
		console.log("Register id : " + $scope.regId);
    else if (notification.event == "message") {
        $cordovaDialogs.alert(notification.message, "Push Notification Received");
        $scope.$apply(function () {
    else if (notification.event == "error")
        $cordovaDialogs.alert(notification.msg, "Push notification error event");
    else $cordovaDialogs.alert(notification.event, "Push notification handler - Unprocessed Event");

I see you’re trying to implement the ngCordova wrapper for the push notifications plugin.

When I tried doing that I realized so many functions were outdated…

I recommend reading my reply to this other thread and implementing the latest methods/plugins to do what you’re trying to do:

Does the application get to this function after register in Android?

Thanks for the code. Its working now :slight_smile:

1 Like

No problem
Glad to help :slight_smile:

so what was the solution? maybe others can learn from it :slight_smile:

Check out the link I shared earlier ^

@ihadeed well I already have pushnotification working :slight_smile: … I was more interested what he did wrong and how he corrected it.

Oh I see.

When I did it his way I remember I faced some issues because the ngCordova implementation was outdated. Which led me to implementing the plugin’s original documentation.