ERROR:使用OneSignal进行推送注册时遇到错误:Error Domain = OneSignalError Code = 400“

问题描述 投票:7回答:1

这是白人,我将一个信号集成到我的iOS应用中时遇到了问题我遵循离子指南和单信号中的所有内容但收到此错误

错误:使用OneSignal进行推送注册时遇到错误:错误域= OneSignalError代码= 400“(null)” UserInfo = {返回= {错误=(“找不到app_id。您可能缺少Content-Type:application / json标头。”); }}

我确定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 = {返回= {错误=(“找不到app_id。您可能缺少Content-Type:application / json标头。”);}}2018-09-20 09:48:39.056130 + 0100婴儿时装[514:115983]错误:使用OneSignal进行电子邮件注册时遇到错误:(null)

感谢您的帮助

xcode ionic-framework push-notification onesignal
1个回答
0
投票

[您需要尽快启动OneSignal,否则当应用尝试将插件与ios挂钩时,它将无法提供app_id,并且会引发错误。

并且您在platform.ready方法中包含代码,因此oneSignal在插件尝试挂接时花了一些时间进行初始化。

您还需要设置Firebase项目ID才能为Android应用启用推送通知。

© www.soinside.com 2019 - 2024. All rights reserved.