react-nativemobileiottuya

How to identify a mobile app user when connecting to Wi-Fi?


There is a home automation built with Tuya Smart IoT platform. It is used for guest house and has some scenarios, like welcoming guests, opening doors, powering on the light, etc.

Visitors book this house via mobile app (built with React Native). Is there a possibility to identify user in mobile app, so that when he connects to Wi-Fi router, some scenario is triggered?

Tuya IoT is able to run scenarios when new device is connected, but how to determine whether connected device is exactly the same that booked this house from app? It’s not possible to read device’s IMEI or MAC-address, so have no idea how to implement this identification.


Solution

  • npm i react-native-network-info

    import { NetworkInfo } from "react-native-network-info";
    
    
    
    // Get Local IP
    NetworkInfo.getIPAddress().then(ipAddress => {
      console.log(ipAddress);
    });
     
    // Get IPv4 IP (priority: WiFi first, cellular second)
    NetworkInfo.getIPV4Address().then(ipv4Address => {
      console.log(ipv4Address);
    });
     
    
    // Get Broadcast
    NetworkInfo.getBroadcast().then(broadcast => {
      console.log(broadcast);
    });
     
    
    // Get SSID
    NetworkInfo.getSSID().then(ssid => {
      console.log(ssid);
    });
    
    
    
    // Get BSSID
    NetworkInfo.getBSSID().then(bssid => {
      console.log(bssid);
    });
    
    
    
    // Get Subnet
    NetworkInfo.getSubnet().then(subnet => {
      console.log(subnet);
    });
     
    
    // Get Default Gateway IP
    NetworkInfo.getGatewayIPAddress().then(defaultGateway => {
      console.log(defaultGateway);
    });
    
    
    
    // Get frequency (supported only for Android)
    NetworkInfo.getFrequency().then(frequency => {
      console.log(frequency);
    });