世博会推送通知已停止生产

时间:2018-11-07 18:25:59

标签: push-notification expo

我正在使用Expo来同时开发Android和iOS。通知运行了好几个星期后,即使没有在这段时间内更新应用程序,也没有停止生产的地方。

服务器端,一切仍然正常,并且正在推送通知。在开发人员中,通知仍然可以正确接收和处理,但是在生产中,这就是s。

其他人是否经历过/可能是什么原因造成的?

这是我的代码:

class Dashboard extends Component {

  constructor(props) {
    super(props);
    this.state = {
      notificationsSet: false,
    }

  }

  componentDidMount() {
    this.registerForPushNotificationsAsync(this.props.currentUser.currentUser.id, this.props.currentUser.authToken)

   savePushToken = (userId, pushToken, token) => {
    //API call to save push token to database
    apiHelper
      .savePushToken(userId, pushToken, token)
      .then(res => {
        return
      })
      .catch(err => console.log("err saving", err));
  };

  handleNotification = notification => {
    this.props.setNotification({ notification })
  }

  registerForPushNotificationsAsync = async (userId, token) =>{
    //requesting if user would like to turn on notifications
    const { status: existingStatus } = await Permissions.getAsync(
      Permissions.NOTIFICATIONS
    );
    //this checks if notifications is turned on for the app --- "granted"
    let finalStatus = existingStatus;
    if (existingStatus !== "granted") {
      const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);

      finalStatus = status;
    }
    if (finalStatus !== "granted") {
      return;
    }    //if "granted" then get push notifications and calls this.savepushtoken to save into the API

    let pushToken = await Notifications.getExpoPushTokenAsync();

    this.subscription = Notifications.addListener(this.handleNotification);
    this.savePushToken(userId, pushToken, token);
  };

     render() {
      return(...)
     }
  }

0 个答案:

没有答案