首页 > 解决方案 > ionic 3上的集成推送firebase通知

问题描述

我正在尝试使用firebase推送,我的代码是正确的,我放置了一个console.log来查看它是否有权限,如果一切都正确,但是当我通过firebase发送通知时。我什么都没有。。

app.component.ts

.then((res: any) => {

    if (res.isEnabled) {
      console.log('We have permission to send push notifications');

    } else {
      console.log('We do not 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('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))

配置文件

<platform name="ios">
    <resource-file src="GoogleService-Info.plist" />
</platform>
<plugin name="phonegap-plugin-push" spec="^2.1.3">
    <variable name="SENDER_ID" value="1064226096335" />
</plugin>

xcode 中的控制台

01:30:14.735620-0300 Myapp[4390:567615] FCM Sender ID 1064226096335
2018-06-08 01:30:14.735644-0300 Myapp[4390:567615] Using FCM Notification
2018-06-08 01:30:14.897536-0300 Myapp[4390:567453] FCM token is null
2018-06-08 01:30:14.898198-0300 Myapp[4390:567453] We have permission to send push notifications
2018-06-08 01:30:14.902557-0300 Myapp[4390:567453] Push Plugin register success: <c1e83f2d 3a9c1fd2 0115d192 4f3d27ce 53c217d3 4b861176 ff65cbac c4ceae9d>

火力基地

在此处输入图像描述

标签: firebaseionic-frameworkpush-notificationionic3

解决方案


推荐阅读