【问题标题】:Sending push notification using ionicframework cloud api使用 ionicframework cloud api 发送推送通知
【发布时间】:2016-11-10 18:02:16
【问题描述】:

您好,我正在尝试从我的 nodejs 服务器向 ionicframework API 发送推送通知,但这里出现错误是我的代码

var token = '66a5c472b52d3210b591f717b5b996312f8xxxxxxxxxxxx';
var title = 'test';
var message = 'message';

var options = {
  method: 'POST',
  url: 'https://api.ionic.io/push/notifications',
  headers: {
    'Authorization': 'Bearer ' + token,
    'Content-Type': 'application/json'
  },
  json : {
    "send_to_all": true,
    "profile" : "my-profile",
    "notification": {
      "title": title,
      "message": message,
      "android": {
        "title": title,
        "message": message
      },
      "ios": {
        "title": title,
        "message": message
      }
    }

  }
};

request(options, function(err, response, body) {
  if (err) throw new Error(err);
  console.log(body);
});

收到此错误

{ error: 

{ 消息:'发生 JWT 解码错误。', 链接:空, 类型:'未经授权'}, 元: {状态:401, 版本:'2.0.0-beta.0', request_id: '75726406-3060-4329-a59e-3bd7f9ca90c8' } }

我做错了什么

【问题讨论】:

    标签: ionic-framework ionic2


    【解决方案1】:

    我认为您的授权标头存在问题。 在标头中放置令牌,但请确保它是 API 令牌。
    还要先发出邮递员请求并检查它是否工作正常。 仅在标题中添加内容类型和授权部分..

    然后检查差异..

    谢谢 巴苏

    【讨论】:

      猜你喜欢
      • 2017-11-16
      • 1970-01-01
      • 2020-09-03
      • 1970-01-01
      • 1970-01-01
      • 2015-08-19
      • 1970-01-01
      • 2020-12-31
      • 2019-11-07
      相关资源
      最近更新 更多