2017-10-14 2 views
0

Cette erreur s'est produite lorsque je cours sur android. J'utilise @ ionic-native/push pour recevoir le noti push de mon serveur nodejs. Voici ma config: Component.ts:Erreur non détectée: Impossible de résoudre tous les paramètres pour PushObject: (?)

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)); 
    } 

mes app.modules.ts:

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

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

Quelqu'un peut-il me aider?

Répondre

1

Ne pas inclure le PushObject dans le tableau des fournisseurs, seule la classe Push (puisque c'est le fournisseur):

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

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