离子通知没有声音

时间:2015-10-08 05:37:24

标签: android ios cordova push-notification ionic

看起来过去几周内离子推送通知发生了一些变化。

OLD WAY

$ionicPush.register({
      canShowAlert: true, //Can pushes show an alert on your screen?
      canSetBadge: true, //Can pushes update app icon badges?
      canPlaySound: true, //Can notifications play a sound?
      canRunActionsOnWake: true, //Can run actions outside the app,
      onNotification: function(notification) {
        // Handle new push notifications here
        alert(notification);
        return true;
      }
    });

enter image description here

新方式

$ionicPush.init({
  "debug": true,
  "onNotification": function(notification) {
    var payload = notification.payload;
    console.log(notification, payload);
  },
  "onRegister": function(data) {
    console.log(data.token);
});

$ionicPush.register();

enter image description here

您可以看到最新版本中的不同代码阻止iOS拥有声音和其他功能。我尝试在canPlaySound: true中添加$ionicPush.init,但它没有用。

如何取回ios的所有通知功能列表?

更新

正确答案

$ionicPush.init({
  "debug": true,
  "onNotification": function(notification) {
    var payload = notification.payload;
    console.log(notification, payload);
  },
  "onRegister": function(data) {
    console.log(data.token);
  },
  "pluginConfig": {
    "ios": {
      "badge": true,
      "sound": true
     },
     "android": {
       "iconColor": "#343434"
     }
  }
});

1 个答案:

答案 0 :(得分:2)

这些是我添加到文档中的插件选项:

http://docs.ionic.io/docs/push-usage#section-plugin-options