简体   繁体   English

在本机移动应用程序上检测特定的 wifi 连接

[英]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.

相关问题 React Native App 不发送移动数据请求,但可以在 wifi 上运行 android - React Native App not sending requests on mobile data but works on wifi android 在 React Native 移动应用中检测相机的高度和宽度 - Detecting camera's height and width in a React Native mobile app 通过移动设备相机检测特定图像 - Detecting specific images through mobile device camera 如何阻止我的用户在他们的手机上打开我的 React Native 应用程序,直到他们不会打开他们的 wifi 或移动数据? - How can I stop my user to open my React Native app on their phone until they will not turn on their wifi or mobile data? 如何发送和接收数据wifi热点板以响应本机应用程序? - how to send and receive data wifi hotspot board to for react native app? 通过JavaScript在移动版Safari中检测应用顶部的双击 - Detecting doubletap on app top in mobile Safari via JavaScript LTE至WIFI连接不适用于WebRTC连接,但Wifi至Wifi可以 - LTE to WIFI connections not working for WebRTC connection but Wifi to Wifi does 通过浏览器打开本机应用(非移动) - Open native app from browser (not mobile) 如何在本机移动应用程序中记录用户操作? - How to record user actions in native mobile app? 带有 Expo 的 React Native Mobile 应用程序中的 Cookies 问题 - Cookies issues in React Native Mobile app with Expo
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM