Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cordova Ionic OneSignal推送通知崩溃IOS 14+;开机设备_Cordova_Ionic Framework_Push Notification_Apple Push Notifications_Push - Fatal编程技术网

Cordova Ionic OneSignal推送通知崩溃IOS 14+;开机设备

Cordova Ionic OneSignal推送通知崩溃IOS 14+;开机设备,cordova,ionic-framework,push-notification,apple-push-notifications,push,Cordova,Ionic Framework,Push Notification,Apple Push Notifications,Push,我在IOS上的应用程序一直存在问题,该应用程序声称位于OneSignalPush.m的第194行。我正在创建一个具有推送通知功能的Ionic 4应用程序。这似乎在较旧的IOS设备上运行得很好,但较新的IOS设备(IOS 14+)似乎会崩溃 崩溃回溯跟踪的最后10项是: Last Exception Backtrace: 0 CoreFoundation 0x1af14a5ac __exceptionPreprocess + 220 (NSException

我在IOS上的应用程序一直存在问题,该应用程序声称位于OneSignalPush.m的第194行。我正在创建一个具有推送通知功能的Ionic 4应用程序。这似乎在较旧的IOS设备上运行得很好,但较新的IOS设备(IOS 14+)似乎会崩溃

崩溃回溯跟踪的最后10项是:

Last Exception Backtrace:
0   CoreFoundation                  0x1af14a5ac __exceptionPreprocess + 220 (NSException.m:199)
1   libobjc.A.dylib                 0x1c323842c objc_exception_throw + 60 (objc-exception.mm:565)
2   CoreFoundation                  0x1af054a2c -[NSObject(NSObject) doesNotRecognizeSelector:] + 144 (NSObject.m:146)
3   CoreFoundation                  0x1af14d130 ___forwarding___ + 1444 (NSForwarding.m:3597)
4   CoreFoundation                  0x1af14f420 _CF_forwarding_prep_0 + 96
5   School Bozza                    0x1042d7620 -[OneSignalPush init:] + 676 (OneSignalPush.m:194)
6   School Bozza                    0x10432c68c 0x1042bc000 + 460428
7   School Bozza                    0x1042c7a90 -[CDVWKWebViewEngine handleCordovaMessage:] + 180 (CDVWKWebViewEngine.m:616)
8   School Bozza                    0x1042c794c -[CDVWKWebViewEngine userContentController:didReceiveScriptMessage:] + 124 (CDVWKWebViewEngine.m:602)
9   School Bozza                    0x1042c8c14 -[CDVWKWeakScriptMessageHandler userContentController:didReceiveScriptMessage:] + 100 (CDVWKWebViewEngine.m:822)
10  WebKit                          0x1bb3bd4c4 ScriptMessageHandlerDelegate::didPostMessage(WebKit::WebPageProxy&, WebKit::FrameInfoData&&, API::ContentWorld&, WebCore::SerializedScriptValue&) + 232 (WKUserContentController.mm:148)
第5行告诉我们我认为是罪魁祸首

我已经尝试过的事情:

  • Podfile的旧版本
  • 删除并添加回ios平台
  • 删除并添加cordova插件
  • cordova插件的不同版本
  • 添加“setTimeout”以稍微延迟初始化
似乎什么都不管用。我正在平台内的app.component.ts中初始化。就绪功能如下:

initializeApp() {
    this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      this.splashScreen.hide();
      setTimeout(() => {
        this.oneSignalInit();
        this.uId.get().then((uuid: any) => {});
      }, 1000);
    });
  }
oneSignalInit() {
    try {
      // set onesignal id
      const oldId = localStorage.getItem('onesignal_id');
      if (oldId && oldId.length > 0) {
        console.log('We have already registered with one signal');
      } else {
        if (this.platform.is('ios')) {
          this.oneSignal.addTrigger("prompt_ios", "true");
          this.oneSignal.startInit(environment.ONESIGNAL_APP_ID, '');
        } else {
          this.oneSignal.startInit(environment.ONESIGNAL_APP_ID, environment.FIREBASE_SENDERID);
        }
        // notification configuration
        this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification); 
        this.oneSignal.setSubscription(true);
        this.oneSignal.enableVibrate(true);
        this.oneSignal.enableSound(true);
        try {
          // get unique id from onesignal and register with device
          this.oneSignal.getIds().then((usersIds: any) => {
            console.log('Registered with onesignal');
            localStorage.setItem('onesignal_id', usersIds.userId);
          }).catch((err: any) => {
            console.log(err, 'one');
          });
        } catch (e) {
          console.log(e);
        }
      }
      this.oneSignal.endInit();
    } catch (e) {
      console.log(e, 'try');
      this.oneSignal.endInit();
    }
  }
然后我像这样运行init:

initializeApp() {
    this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      this.splashScreen.hide();
      setTimeout(() => {
        this.oneSignalInit();
        this.uId.get().then((uuid: any) => {});
      }, 1000);
    });
  }
oneSignalInit() {
    try {
      // set onesignal id
      const oldId = localStorage.getItem('onesignal_id');
      if (oldId && oldId.length > 0) {
        console.log('We have already registered with one signal');
      } else {
        if (this.platform.is('ios')) {
          this.oneSignal.addTrigger("prompt_ios", "true");
          this.oneSignal.startInit(environment.ONESIGNAL_APP_ID, '');
        } else {
          this.oneSignal.startInit(environment.ONESIGNAL_APP_ID, environment.FIREBASE_SENDERID);
        }
        // notification configuration
        this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification); 
        this.oneSignal.setSubscription(true);
        this.oneSignal.enableVibrate(true);
        this.oneSignal.enableSound(true);
        try {
          // get unique id from onesignal and register with device
          this.oneSignal.getIds().then((usersIds: any) => {
            console.log('Registered with onesignal');
            localStorage.setItem('onesignal_id', usersIds.userId);
          }).catch((err: any) => {
            console.log(err, 'one');
          });
        } catch (e) {
          console.log(e);
        }
      }
      this.oneSignal.endInit();
    } catch (e) {
      console.log(e, 'try');
      this.oneSignal.endInit();
    }
  }

如果有人能提供帮助,那将是令人惊讶的,我甚至无法想象这个问题会是什么,其他人似乎不会面临同样的问题,所以我一定是在做一些愚蠢的事情。

好吧,我发现了这个问题,所以在我的应用程序初始化中,我使用了:

this.oneSignal.startInit(environment.oneSignal\u APP\u ID')

但问题实际上是一个空字符串,这意味着应用程序没有成功导入变量:“environment.ONESIGNAL\u app\u ID”

我通过简单地在实际的“OneSignalPush.m”文件中硬编码应用程序ID来修复这个问题。。。这不是一个好的做法,但它可以阻止应用程序崩溃