JPush设置别名失败
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);
});
}
}
报错信息如下所示:
他只会在初始化的时候设置别名失败!在第一次失败之后手动设置别名可以成功,我没找到相关的文档,求帮忙