ios - Expo.Notifications.addListener() 未触发(iOS 独立应用程序)
问题描述
我正在尝试在我的组件中使用 Expo.Notifictions.addListener(在 iOS 独立版本上),但尽管成功接收到通知,但它不会触发。
addListener() 被放置在componentDidMount()
函数内部。
Expo.Notifications.addListener(this.handleNotification);
handleNotification = () => {
this.setState({
something: 3,
});
};
解决方案
您没有将回调添加到您的 addListener 函数中。
componentDidMount(){
Notifications.addListener(notification => {
console.log(notification);
});
}
推荐阅读
- c# - ASP.NET Core IIS Express AD 服务权限错误
- javascript - 没有任何 YouTube javascript 加载到 html 页面中
- html - 子锚标记获得焦点时的大纲列表项
- google-cloud-platform - 需要获取自上次在 gcp 中停止实例以来的时间数据
- c# - 在虚拟助手上启用 QnA 跟进提示
- sql - 如何从 Microsoft SQL Server 中的字符串中修剪字符?
- python - 多个按钮在 PyQt5 python 中不起作用
- angular - 角度复选框状态检查经常触发
- powershell - 应该在 Assert-MockCalled 的 ParameterFilter 中不能按预期工作
- mysql - 更新查询不起作用 7-8% 的记录