ionic-team/legacy-ionic-cloud

Ionic push notification doesn’t work when app is closed

Closed this issue · 1 comments

I implemented Ionic push service in my application. But it just works when the app is opened or is in background. When I close the app, the device doesn't receive any notification (Tested in android). My codes:

In app.js

  $ionicCloudProvider.init({
    "core": {
      "app_id": "..."
    },
    "push": {
      "sender_id": "...",
      "pluginConfig": {
        "ios": {
          "badge": true,
          "sound": true
        },
        "android": {
          "iconColor": "#343434"
        }
      }
    }
  });

In controller:

    $ionicPush.register().then(function(t) {
        alert(JSON.stringify(t));
        opt = {ignore_user: true};
        return $ionicPush.saveToken(t, opt);
    }).then(function(t) {
        alert('Token saved:', t.token);
    });

    $rootScope.$on('cloud:push:notification', function(event, data) {
        var msg = data.message;
        alert(msg.title + ': ' + msg.text);
    });

Any idea??

This is a problem with Huawei devices. There is a feature called protected app. If the app is not in protected mode, it won't receive any notification. But how can I set the app to protected mode by default?