2017-10-14 84 views
0

當我在android上運行時發生此錯誤。未捕獲的錯誤:無法解析PushObject的所有參數:(?)

我正在使用@ ionic-native/push從我的nodejs服務器接收推送noti。 這是我的配置: 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)); 
    } 

我app.modules.ts:

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

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

誰能幫助我?

回答

1

不包括提供一個存儲在PushObject,只有Push類(因爲這是供應商):

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

providers: [ 
... 
    Push, 
...] 
相關問題