未捕获错误:无法解析推送对象的所有参数:(?)



当我在安卓上运行时发生了此错误。

我正在使用@ionic-native/push从我的nodejs服务器接收推送通知。这是我的配置:Component.ts:

initPushNotification() {
    const options: PushOptions = {
      android: {},
      ios: {
          alert: 'true',
          badge: true,
          sound: 'false'
      },
      windows: {},
      browser: {
          pushServiceURL: 'http://push.api.phonegap.com/v1/push'
      }
   };
    const pushObject: PushObject = this.push.init(options);
    pushObject.subscribe('topic').then(() => {
      console.log('subscribe success to topic')
    }).catch((e) => {
      console.log(e)
    })
    pushObject.on('registration').subscribe((data: any) => {
      console.log('device token -> ' + data.registrationId);
      //TODO - send device token to server
    });
    pushObject.on('notification').subscribe((notification: any) => {
      console.log('Received a notification', notification)
    });
    pushObject.on('error').subscribe(error => console.error('Error with Push plugin' + error));
  }

我的应用程序模块.ts:

import { Push, PushObject } from '@ionic-native/push';
providers: [
...
    Push, PushObject,
...]

谁能帮我?

不要在提供程序数组中包含PushObject,而只包含Push类(因为这是提供程序):

import { Push } from '@ionic-native/push';
providers: [
...
    Push,
...]

相关内容

  • 没有找到相关文章

最新更新