【问题标题】:Firebase push notifications with Ionic3 works on iOS but not on Android带有 Ionic3 的 Firebase 推送通知适用于 iOS,但不适用于 Android
【发布时间】:2018-07-02 23:59:13
【问题描述】:

this 和我的代码使用本机离子推送,在 ios 中运行正常,当我启动 ``this.push.init(options); 它向用户请求权限并且它工作正常,但是在android中它什么也没有发生,不要进入这些方法

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

  if (res.isEnabled) {
    alert('have permission');

    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) => {
        alert(notification.message);
      });

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

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

  } else {
    alert('don`t have permission');
  }

});

--

 <plugin name="phonegap-plugin-push" spec="^2.0.0">
        <variable name="SENDER_ID" value="32673134" />
    </plugin>
    <platform name="android">
        <resource-file src="google-services.json" target="google-services.json" />
    </platform>

【问题讨论】:

    标签: android firebase ionic-framework ionic3 firebase-cloud-messaging


    【解决方案1】:

    请使用 Onsignal 推送通知。这很容易。
    https://documentation.onesignal.com/docs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-22
      • 2018-05-25
      • 2018-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多