【问题标题】:handling expo push notifications when app is closed关闭应用程序时处理博览会推送通知
【发布时间】:2020-08-30 13:09:39
【问题描述】:

世博 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,但是当应用程序关闭时,句柄函数根本没有执行? 有人可以帮忙吗?

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

    • 嗯,为什么外观样式有助于修复推送可见性?
    • @Kate 显然是一个展览错误
    • 是的,除非我应用此答案中的设置,否则我不会收到通常由 Expo 发送到根组件的 exp.notification 道具。
    • 另外,一旦我应用了这些设置,我可以恢复它们,exp.notification 将继续被正确接收。
    猜你喜欢
    • 2013-04-19
    • 1970-01-01
    • 2018-11-14
    • 1970-01-01
    • 2016-05-05
    • 1970-01-01
    • 1970-01-01
    • 2016-06-09
    • 1970-01-01
    相关资源
    最近更新 更多