[英]Detecting specific wifi connections on a native mobile app
I am looking at ways to detect when a specific connection is available.我正在寻找检测特定连接何时可用的方法。 For example when the user gets home and the network is picked up they are able to be given a notification as to whether they would like to join the network.
例如,当用户回到家并且网络被接通时,他们能够得到关于他们是否想要加入网络的通知。 At the minute I am trying to do this in React so would be interested in what options I have available native or not.
目前我正在尝试在 React 中执行此操作,因此会对我有哪些可用的本机选项感兴趣。
I have seen this previous question which is along very similar lines but I am not currently looking specifically for android.我已经看到了这个以前的问题,它是非常相似的,但我目前不是专门针对 android 寻找的。 Android WIFI How To Detect When Specific WIFI Connection is Available
Android WIFI 如何检测特定 WIFI 连接何时可用
You should use NetInfo
for this.为此,您应该使用
NetInfo
。 You can find specific documentation here .您可以在此处找到特定文档。
Here is a quick example of what you are trying to do:这是您尝试执行的操作的快速示例:
NetInfo.addEventListener(
'change',
function(reach) {
if(reach.toLowerCase() === 'wifi' ) {
console.log('You are on wifi!');
}
}
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.