仅在单击按钮后才提示用户允许位置,通知等时,是否需要使用ComponentDidMount?]

问题描述 投票:0回答:1
我正在尝试创建我的第一个React Native App,所以我从expo开始,但是componentDidMount遇到了问题。

根据我所看到的,提示用户允许通知,位置等;如果以前没有询问过用户,则使用componentDidMount会在屏幕开始时提示用户。但是,我想通过以下操作提示用户:

code to call _getLocation with button press

此为_getLocation:_getLocation code

我可以使用_getNotification做同样的事情,只需在TouchableOpacity的onPress上调用它即可。

但是这会影响以后的通知吗?是否需要在render中初始化componentDidMount以便以后发送通知?这样做将来会带来什么后果?

很难找到有关此的信息,谢谢您的任何答复和建议。

我正在尝试创建我的第一个React Native App,所以我从expo开始,但是componentDidMount出现了问题。从我所看到的,要提示用户允许通知,...

react-native push-notification location expo expo-permissions
1个回答
0
投票
不! componentDidMount只是反应生命周期方法,因此不会影响收集权限。
© www.soinside.com 2019 - 2024. All rights reserved.