@capgo/capgo-skills
Version:
55 agent skills for Capacitor mobile development
34 lines (22 loc) • 846 B
Markdown
Network and connectivity information.
**Platforms:** Android, iOS, Web
```bash
npm install @capacitor/network
npx cap sync
```
```typescript
import { Network } from '@capacitor/network';
const status = await Network.getStatus();
console.log('Connected:', status.connected, 'Type:', status.connectionType);
const handle = await Network.addListener('networkStatusChange', (status) => {
console.log('Network changed:', status.connectionType);
});
// Cleanup when the listener is no longer needed.
await handle.remove();
```
- `connected`: boolean connectivity flag. It is usually `false` when `connectionType` is `'none'`, `true` for `'wifi'` or `'cellular'`, and should be treated as undetermined when the type is `'unknown'`.
- `connectionType`: `'wifi' | 'cellular' | 'none' | 'unknown'`.