Skip to content

Commit

Permalink
fix: Fix Android 10 no-internet support (#82)
Browse files Browse the repository at this point in the history
Co-authored-by: Elias Lecomte <elias.lecomte@inthepocket.com>
Co-authored-by: Thibault Maekelbergh <thibault.maekelbergh@icloud.com>
  • Loading branch information
3 people authored May 23, 2020
1 parent 75c52cf commit 45d626c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
15 changes: 11 additions & 4 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@ Nodeunit contributors (sorted alphabetically)
* **[eliaslecomte](https://github.com/eliaslecomte)**

* Update gradle configuration
* Update all Library in Android

* Update Android library
* Use [WifiUtils](https://github.com/ThanosFisherman/WifiUtils/)
* Use promises over callbacks
* Return meaningful exceptions

* **[kristfal](https://github.com/kristfal)**

* [android] rename the default name of package
* [android] Rename the default name of package

* **[Rapsssito](https://github.com/Rapsssito)**

* [android] added network compatibility
* [android] Added network compatibility

* **[gabrielrra](https://github.com/gabrielrra)**

* [docs] Update docs

* **[thibmaek](https://github.com/thibmaek)**

* [docs] Added type declarations
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.android.tools.build:gradle:3.6.3'
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
buildToolsVersion '29.0.3'

defaultConfig {
minSdkVersion 21
Expand All @@ -36,6 +36,6 @@ dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+'

implementation 'com.thanosfisherman.wifiutils:wifiutils:1.5.1'
implementation 'com.thanosfisherman.wifiutils:wifiutils:1.6.1'
}

14 changes: 8 additions & 6 deletions android/src/main/java/com/reactlibrary/rnwifi/RNWifiModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.reactlibrary.utils.LocationUtils;
import com.reactlibrary.utils.PermissionUtils;
import com.thanosfisherman.wifiutils.WifiUtils;
import com.thanosfisherman.wifiutils.wifiConnect.ConnectionErrorCode;
import com.thanosfisherman.wifiutils.wifiConnect.ConnectionSuccessListener;

import org.json.JSONArray;
Expand Down Expand Up @@ -182,12 +183,13 @@ public void connectToProtectedSSID(@NonNull final String SSID, @NonNull final St

WifiUtils.withContext(context).connectWith(SSID, password).onConnectionResult(new ConnectionSuccessListener() {
@Override
public void isSuccessful(boolean isSuccess) {
if (isSuccess) {
promise.resolve("connected");
} else {
promise.reject("failed", "Could not connect to network");
}
public void success() {
promise.resolve("connected");
}

@Override
public void failed(@NonNull ConnectionErrorCode errorCode) {
promise.reject("failed", "Could not connect to network");
}
}).start();
}
Expand Down

0 comments on commit 45d626c

Please sign in to comment.