关闭应用程序时处理世博会推送通知

handling expo push notifications when app is closed

世博会 SDK 37

componentDidMount() {
this.registerForPushNotificationsAsync();
this._notificationSubscription = Notifications.addListener(this._handleNotification);
}
_handleNotification = notification => {
Vibration.vibrate();
console.log(notification);
console.log(“hello”)
this.setState({ notification: notification });
};

当应用程序前台时执行句柄函数并执行console.log但是当应用程序关闭时句柄函数根本不执行? 有人可以帮忙吗?

通过在 app.json 文件中添加这个来解决它

{
  "expo": {
    "userInterfaceStyle": "automatic",
    "ios": {
      "userInterfaceStyle": "light"
    },
    "android": {
      "userInterfaceStyle": "dark"
    }
  }
}