Ionic-OneSignal在iOS 13.x上不起作用

时间:2019-11-25 20:09:45

标签: ios xcode ionic-framework apple-push-notifications onesignal

我的ionic 3应用程序和OneSignal出现问题。

该应用程序在Android版本和iOS版本12.x上均可正常运行,但在iOS 13. *上则没有任何反应。

在OneSignal仪表板中查看未注册的设备。我也没有在我的应用程序中获得玩家ID(调用getIds()方法)。

app.component.ts:

  constructor(platform: Platform, 
              statusBar: StatusBar, 
              private oneSignal: OneSignal,
              public api: ApirestProvider,
              private alertCtrl: AlertController,
              splashScreen: SplashScreen) {
    platform.ready().then(() => {
      statusBar.styleDefault();
      splashScreen.hide();
      this.handlerNotifications();
    });
  }

  private handlerNotifications(){
    this.oneSignal.startInit('xxxxxxxxxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxx');
    this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification);
    this.oneSignal.handleNotificationOpened()
    .subscribe(jsonData => {
      let alert = this.alertCtrl.create({
        title: jsonData.notification.payload.title,
        subTitle: jsonData.notification.payload.body,
        buttons: ['OK']
      });
      alert.present();
    });

    this.oneSignal.getIds().then(identity => {
      console.log("Player ID:" + identity.userId);
      this.api.player_id=identity.userId;
    }).catch(err => {
      this.api.showMsg("Error en getIds():" + err);
    }); 

    this.oneSignal.endInit();

  }

离子信息:

Ionic:

   Ionic CLI          : 5.4.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.1

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : ios 4.5.5
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.1, (and 14 other plugins)

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v10.16.3 (/usr/local/bin/node)
   npm    : 6.9.0
   OS     : macOS Mojave
   Xcode  : Xcode 11.2.1 Build version 11B500

cordova插件列表:

cordova-open-native-settings 1.5.2 "Native settings"
cordova-plugin-actionsheet 2.3.3 "ActionSheet"
cordova-plugin-advanced-http 2.0.2 "Advanced HTTP plugin"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-dialogs 2.0.1 "Notification"
cordova-plugin-email-composer 0.9.1 "EmailComposer"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-googlemaps 2.4.6 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 2.3.1 "cordova-plugin-ionic-webview"
cordova-plugin-network-information 2.0.2 "Network Information"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
mx.ferreyra.callnumber 0.0.2 "Cordova Call Number Plugin"
onesignal-cordova-plugin 2.4.6 "OneSignal Push Notifications"

在XCODE iPhone模拟器(目标iOS 13.2.2 / iPhone 11)上运行项目可以正常工作,进行订阅并获取播放器ID。

它仅在实际设备iPhone 13.x上不起作用。

有什么建议吗?

最佳角色

1 个答案:

答案 0 :(得分:1)

使用2.6.0或更高版本更新onesignal插件,然后在ios 13中运行正常。