mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(core): nativescript.config and webpack updates (#8801)
This commit is contained in:
40
apps/automated/src/connectivity/connectivity-tests.ts
Normal file
40
apps/automated/src/connectivity/connectivity-tests.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
// >> connectivity-require
|
||||
import * as connectivity from '@nativescript/core/connectivity';
|
||||
// << connectivity-require
|
||||
|
||||
export var test_DummyTestForSnippetOnly0 = function () {
|
||||
// >> connectivity-type
|
||||
var connectionType = connectivity.getConnectionType();
|
||||
switch (connectionType) {
|
||||
case connectivity.connectionType.none:
|
||||
//console.log("No connection");
|
||||
break;
|
||||
case connectivity.connectionType.wifi:
|
||||
//console.log("WiFi connection");
|
||||
break;
|
||||
case connectivity.connectionType.mobile:
|
||||
//console.log("Mobile connection");
|
||||
break;
|
||||
}
|
||||
// << connectivity-type
|
||||
};
|
||||
|
||||
export var test_DummyTestForSnippetOnly1 = function () {
|
||||
// >> connectivity-monitoring
|
||||
connectivity.startMonitoring(function onConnectionTypeChanged(newConnectionType: number) {
|
||||
switch (newConnectionType) {
|
||||
case connectivity.connectionType.none:
|
||||
//console.log("Connection type changed to none.");
|
||||
break;
|
||||
case connectivity.connectionType.wifi:
|
||||
//console.log("Connection type changed to WiFi.");
|
||||
break;
|
||||
case connectivity.connectionType.mobile:
|
||||
//console.log("Connection type changed to mobile.");
|
||||
break;
|
||||
}
|
||||
});
|
||||
//...
|
||||
connectivity.stopMonitoring();
|
||||
// << connectivity-monitoring
|
||||
};
|
||||
19
apps/automated/src/connectivity/connectivity.md
Normal file
19
apps/automated/src/connectivity/connectivity.md
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
nav-title: "connectivity How-To"
|
||||
title: "connectivity"
|
||||
environment: nativescript
|
||||
description: "Examples for using connectivity"
|
||||
previous_url: /ApiReference/connectivity/HOW-TO
|
||||
---
|
||||
# Connectivity
|
||||
Obtaining connectivity information requires the "connectivity" module.
|
||||
{%snippet connectivity-require%}
|
||||
|
||||
### Getting connection type
|
||||
{%snippet connectivity-type%}
|
||||
|
||||
### Monitoring connection type.
|
||||
{%snippet connectivity-monitoring%}
|
||||
|
||||
### Permissions
|
||||
On Android, the permission ACCESS_NETWORK_STATE is required.
|
||||
Reference in New Issue
Block a user