首页 > 解决方案 > 我使用手机时没有收到“onPushTokenReceivedCallback”

问题描述

当我使用我的 iPhone 时,我没有得到令牌。当我使用模拟器时,我得到了令牌。我使用 nativescript-firebase-plugin 并在 main.js 中执行 firebase.init 功能。

我已经尝试了我在这个错误上找到的所有东西,或者我什至不知道它是否是一个常见错误。完整的初始化看起来像这样

firebase.init({
  showNotifications: true,
  showNotificationsWhenInForeground: true,

  onPushTokenReceivedCallback: (token) => {
    console.log(`onPushTokenReceivedCallback: ${token}`);
    appSettings.setString('firebasemessagekeytoken', token);
  },

  onMessageReceivedCallback: (message) => {
    console.log(`onPushTokenReceivedCallback: ${message.title}`);
  }
})
  .then(() => {
    console.log('[Firebase] Initialized');
  })
  .catch(error => {
    console.log(`error: ${error}`);
  });```

标签: iosfirebasepush-notificationnotificationsnativescript

解决方案


推荐阅读