Ionic数据库插入推送通知

大家好,

我正在使用接收推送通知的Ionic2,运行良好。但我想更进一步。我需要自动化推送通知。我正在使用PHP和mySQL。我也有NodeJS WebApi。在NodeJS或PHP中是否有可能发送Ionic推送通知?我已经按照以下教程在NodeJS中尝试,但是我得到了401 Unauthorized错误:

ionic-push-server

以下是错误内容:

STATUS: 401
HEADERS: {"date":"Thu, 13 Apr 2017 19:13:09 GMT","content-type":"application/json; charset=utf-8","content-length":"196","connection":"close","server":"openresty","via":"1.1 vegur","access-control-allow-credentials":"true","access-control-allow-methods":"HEAD,GET,POST,PATCH,PUT,DELETE,OPTIONS","access-control-allow-headers":"DNT,Authorization,X-CSRFToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type"}
BODY: {"meta": {"version": "2.0.0-beta.0", "status": 401, "request_id": "00000000-1111-2222-3333-444444444444"}, "error": {"link": null, "type": "Unauthorized", "message": "JWT decode error occurred."}}
点赞
用户6786980
用户6786980
var ionicPushServer = require('ionic-push-server');

var credentials = {
    IonicApplicationID : "IonicAppId",
    IonicApplicationAPItoken : "IonicApplicationAPIToken" //需要从应用设置中生成
};

var notification = {
  "tokens": ["your", "device", "tokens"],
  "profile": "AppProfileNameInSmallLetters",
  "send_to_all": true,
  "notification": {
    "title": "Hi",
    "message": "Hello world!",
    "android": {
      "title": "Hey",
      "message": "Hello Android!",
      "payload": {
        "category": "Star"
          }
    },
    "ios": {
      "title": "Howdy",
      "message": "Hello iOS!",
      "payload": {
        "category": "Star"
          }
    }
  }
};

ionicPushServer(credentials, notification);
2017-04-13 20:04:15