ERROR: 遇到 OneSignal 推送注册错误: 错误领域=OneSignalError 代码=400

7

我在将 OneSignal 集成到我的 iOS 应用程序时遇到了问题。我按照 Ionic 指南和 OneSignal 的指南进行了操作,但出现了以下错误:

ERROR: 在与 OneSignal 注册推送期间遇到错误: Error Domain=OneSignalError Code=400 "(null)" UserInfo={returned={ errors = ( "app_id not found. You may be missing a Content-Type: application/json header." ); }}

我确定 app_id 是正确的。

请问有人能提供帮助吗?这是我的代码:

platform.ready().then(() => {


  // Okay, so the platform is ready and our plugins are available.
  // Here you can do any higher level native things you might need.
  statusBar.styleDefault();
  splashScreen.hide();

if(platform.is('ios')){
    console.log('platform is ios using onsignail for ios');
    this.oneSignal.startInit('bae0c3e1-bc4e-49ab-9274-18635XXXXX', );

this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.InAppAlert);

this.oneSignal.handleNotificationReceived().subscribe(() => {
    // do something when notification is received
});

this.oneSignal.handleNotificationOpened().subscribe(() => {
    // do something when a notification is opened
});

this.oneSignal.endInit();

}

这是在Xcode控制台中的输出

错误:在OneSignal推送注册期间遇到错误:OneSignalError领域=错误代码=400“(null)”UserInfo = {returned={ errors = ( "app_id not found. You may be missing a Content-Type: application/json header." ); }} 2018-09-20 09:48:39.056130+0100 Baby Fashion[514:115983] 错误:在OneSignal电子邮件注册期间遇到错误:(null)

感谢您的帮助!


1
你解决了这个问题吗? - Tim Mishutin
1个回答

0

你需要尽快启动OneSignal,否则当应用程序尝试使用插件与iOS进行连接时,它将无法提供app_id并抛出错误。

而且你的代码在platform.ready方法中,因此OneSignal需要时间来初始化,而插件正在尝试进行连接。

你还需要设置Firebase项目ID以启用Android应用程序的推送通知。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接