cannot find user by this audience-使用phonegap 和node服务端

Leglo
2018-06-03 05:15 1.4k 0

客户端使用库:jpush-phonegap-plugin , ionic2-jpush
核心代码:

let user = await this.auth.getUser();
    alert(user._id);
    this.jPushPlugin.setAlias(user._id); //设置别名

this.jPushPlugin.init() //注册
  .then(res => alert(res))
  .catch(err => alert(err))

this.jPushPlugin.isPushStopped() //是否停止
  .then(res => alert(res))
  .catch(err => alert(err))

客户端依次弹出:user._id='123456' , ok , 0;

node服务端:jpush-async

核心代码:

   import * as JPush from 'jpush-async/lib/JPush/JPushAsync.js';

    const jpushappkey = 'xxxx';
    const jpushMasterSecret = 'xxxx';
    export const jpushClient = JPush.buildClient(jpushappkey, jpushMasterSecret);

function sendNotification(info: string, auth?: string) {
  let content = info.substr(0, 30);
  if (content.length !== info.length) content += ' ...';
  let audience = JPush.ALL;
  if (auth) audience = JPush.alias(auth);
  jpushClient
    .push()
    .setPlatform(JPush.ALL)
    .setAudience(audience)
    .setNotification(content)
    .send()
    .then(function(result) {
      console.log('ok');
      console.log(result);
    })
    .catch(function(err) {
      console.log('no');
      console.log(err.message);
    });
}

 const info = 'aaaa';
 const auth = '123456';
let res  = sendNotification(info,auth);

返回结果:no,
Push Fail, HttpStatusCode: 400 result: {"msg_id":20266202734095710,"error":{"message":"cannot find user by this audience","code":1011}}

注明:app_key服务端与客户端一致,master_secret无误。

1个回答

热门排序
  • Leglo
    2018-06-03 06:59

    求大佬们解答