Push notifications with ionic

0

I want to make a push notification of a fixed message every time changes occur in an http request.

For this I am trying to use Ionic Native Push.

I tried something like:

ngOnInit(): void {
    this.push.hasPermission()
    .then((res: any) => {

      if (res.isEnabled) {
        this.dialogs.alert("Habilitado para receber notificações");
        this.push.createChannel({
          id: "novapergunta1",
          description: "Você possui uma nova pergunta, abra o aplicativo para verificar",
          // The importance property goes from 1 = Lowest, 2 = Low, 3 = Normal, 4 = High and 5 = Highest.
          importance: 3
        }).then(() => console.log('Channel created'));

        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.on('notification').subscribe((notification: any) => console.log('Received a notification', notification));

        pushObject.on('registration').subscribe((registration: any) => console.log('Device registered', registration));

        pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error));


      } else {
        this.dialogs.alert("Não está habilitado a receber notificações");
      }

    }); 

I receive the message that is enabled to receive notifications but I do not receive the notification itself.

    
asked by anonymous 20.08.2018 / 14:28

0 answers