Don't insta-crash when network permission is missing

Summary:
public

Rename the `ConnectivityModule` to `NetInfoModule` (there's
no need to name things differently in two places). Add exception
handling to the module in case the network permission is missing.

When the permission is missing, throw an actionable error from
all calls to `NetInfo`: http://imgur.com/zVIMxOV

Without this change, the app immediately crashes on startup:
`getCurrentConnectionType` is called from `Activity.onResume`.

Reviewed By: andreicoman11, bestander

Differential Revision: D2749230

fb-gh-sync-id: 1b752d21a8f28ffeaf60a3322cb76f869dc70a14
This commit is contained in:
Martin Konicek
2015-12-11 10:22:37 -08:00
committed by facebook-github-bot-7
parent 4b800e6ce1
commit f168fc335e
2 changed files with 42 additions and 11 deletions

View File

@@ -20,7 +20,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.modules.fresco.FrescoModule;
import com.facebook.react.modules.intent.IntentModule;
import com.facebook.react.modules.location.LocationModule;
import com.facebook.react.modules.netinfo.ConnectivityModule;
import com.facebook.react.modules.netinfo.NetInfoModule;
import com.facebook.react.modules.network.NetworkingModule;
import com.facebook.react.modules.storage.AsyncStorageModule;
import com.facebook.react.modules.toast.ToastModule;
@@ -57,7 +57,7 @@ public class MainReactPackage implements ReactPackage {
new IntentModule(reactContext),
new LocationModule(reactContext),
new NetworkingModule(reactContext),
new ConnectivityModule(reactContext),
new NetInfoModule(reactContext),
new WebSocketModule(reactContext),
new ToastModule(reactContext));
}