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

时间:2020-05-14 05:26:47

标签: javascript react-native push-notification expo mobile-development

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,但是当应用程序关闭时,将根本不执行句柄功能吗? 有人可以帮忙吗?

1 个答案:

答案 0 :(得分:2)

通过在app.json文件中添加此文件来解决

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