未捕获的错误:无法解析 PushObject 的所有参数:(?)

Tha*_*ynh 2 typescript ionic2 ionic3 angular

当我在 android 上运行时发生了这个错误。

我正在使用 @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));
  }
Run Code Online (Sandbox Code Playgroud)

我的 app.modules.ts:

import { Push, PushObject } from '@ionic-native/push';

providers: [
...
    Push, PushObject,
...]
Run Code Online (Sandbox Code Playgroud)

谁能帮我 ?

seb*_*ras 5

不要PushObject在提供者数组中包含 ,只有Push类(因为那是提供者):

import { Push } from '@ionic-native/push';

providers: [
...
    Push,
...]
Run Code Online (Sandbox Code Playgroud)