JPush设置别名失败

69岁是个码农
2021-01-04 01:28 483 1

Ionic5 极光初学者,安装的相关的依赖为:

cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_jpush_appkey
npm install --save @jiguang-ionic/jpush

我想要实现的功能是在APP启动时设置设备别名为not_login用于向所有未登录的设备进行推送,但是别名会设置失败!代码如下所示

// 这个是AppComponent组件
export class AppComponent {
    constructor(.....private jpushService: JPushService) {
        this.initializeApp();
        this.initJPush();
    }

    initializeApp() {
        this.platform.ready().then(() => {
            this.statusBar.styleDefault();
            this.splashScreen.hide();
        });
    }

    initJPush(){
        console.log("NOT_LOGIN:", NOT_LOGIN);
        this.jpushService.setAlias(NOT_LOGIN);
    }

}
// 封装的JPush服务
export class JPushService {

    constructor( private jpush: JPush ) {
        this.jpush.setDebugMode(true);
        this.jpush.init();
    }

    setAlias(alias){
        let options: AliasOptions = {
            sequence: this.sequence,
            alias: alias
        }
        this.jpush.setAlias(options).then(res=>{
            console.log("设置设备别名成功:", alias);
        }).catch(err=>{
            console.log("设置设备别名失败!", err);
        });
    }
}

报错信息如下所示:

null

他只会在初始化的时候设置别名失败!在第一次失败之后手动设置别名可以成功,我没找到相关的文档,求帮忙

1个回答

热门排序
  • 您是不是还没有初始化成功就开始设置别名了呢。您看一下是否有其他报错信息,从初始化开始收集报错信息。一个别名至多设置10台设备,您是否有设置超过数量呢。您手动设置后,是换了别名吗?

gptbots-widget