【问题标题】:Uncaught Error: Can’t resolve all parameters for PushObject: (?)未捕获的错误:无法解析 PushObject 的所有参数:(?)
【发布时间】:2017-10-14 16:11:15
【问题描述】:

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

我正在使用@ionic-native/push 从我的 nodejs 服务器接收推送通知。 这是我的配置: 组件.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));
  }

我的 app.modules.ts:

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

providers: [
...
    Push, PushObject,
...]

谁能帮帮我?

【问题讨论】:

    标签: angular typescript ionic2 ionic3


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2018-08-22
      • 2018-12-18
      • 2018-09-21
      • 2023-03-16
      • 2019-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多