使用PUSH和FMC的ionic 3推送通知

时间:2018-06-20 15:00:23

标签: xcode firebase ionic-framework push-notification ionic3

我尝试使用Push和FCM,我将显示两个代码 有点了解发生了什么,我正在发送通知,它发送到APP,但是在APP中什么都没有到达 有人可以帮助我,我将非常感激。

** APNS *

APNS CERTICATE FIREBASE结果图像

IMAGE OF FIREBASE HERE

XCODE结果图像

IMAGE OF XCODE HERE

APP.COMPONENTS.TS(使用PUSH)

 platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
      alert('TESTE1');
      this.push.hasPermission()
      .then((res: any) => {
        if (res.isEnabled) {
          alert('We have permission to send push notifications');

          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('--------------------------');
            this.xd = notification ;
            console.log(notification);
            console.log(this.xd.message);
            console.log('--------------------------');
            alert(notification.message);
          });

          pushObject.on('registration').subscribe((registration: any) =>{
            console.log('--------------------------');
            alert( registration);
            console.log('--------------------------');
            console.log(registration);

          });

          pushObject.on('error').subscribe(error =>{ 
            alert(error);
          });


        } else {
          alert('We do not have permission to send push notifications');

        }

      });



    });

现在我将使用FMC显示结果

   platform.ready().then(() => {
      //Notifications
      fcm.subscribeToTopic('all');
      fcm.getToken().then(token=>{
        console.log(token);
      })
      fcm.onNotification().subscribe(data=>{
        if(data.wasTapped){
          console.log("Received in background");
        } else {
          console.log("Received in foreground");
        };
      })
      fcm.onTokenRefresh().subscribe(token=>{
        console.log(token);
      });
      //end notifications.
      statusBar.styleDefault();
      splashScreen.hide();
    });

我的智能手机和XCODE的结果

Image here

0 个答案:

没有答案