How to use link to connect to WiFi in react native

0

How do i use a link in react native to connect to wifi? So i have this piece of code:

import {Linking, Component, Button} from 'react-native';

export default class MyLinkScreen extends Component{

     private connectWifi(){
         Linking.openURL('WIFI:T:WPA;S:SampleSSID;P:SamplePassword;H:false');
     }

     public render(){
         return (
             <Button onPress={()=>this.connectWifi()}>Connect</Button>
         )
     }

}

but i ends up having this error in android: error [Error: Could not open URL 'WIFI:T:WPA;S:SampleSSID;P:SamplePassword;H:false': No Activity found to handle Intent { act=android.intent.action.VIEW dat=WIFI:T:WPA;S:SampleSSID;P:SamplePassword;H:false flg=0x10000000 }]

so any idea on how to make my link to prompt connect to wifi as if we scan the wifi qr code? Thank you.

android
react-native
asked on Stack Overflow Mar 20, 2020 by Hans Yulian

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0