Skip to content

Commit

Permalink
Removed broken/inconsistent links (API reference sections ) from http…
Browse files Browse the repository at this point in the history
….md and connectivity.md and instead made them complete,no need to point other pages
  • Loading branch information
Ombuweb committed Jun 19, 2022
1 parent c7e2507 commit 469929d
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 31 deletions.
30 changes: 12 additions & 18 deletions .vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,27 +534,21 @@ function getSidebar() {
{
text: '@nativescript/core',
children: [
{ text: 'Application', link: '/nativescript-core/application' },
//{text: 'ApplicationSettings',link: '/nativescript-core/application-settings'},
{ text: 'Color', link: '/nativescript-core/color' },
{ text: 'Connectivity', link: '/nativescript-core/connectivity' },
{ text: 'Application', link: '/nativescript-core/application' },
{
text: 'ApplicationSettings',
link: '/nativescript-core/application-settings',
},
{ text: 'Observable', link: '/nativescript-core/observable' },
{
text: 'Observable Array',
link: '/nativescript-core/observable-array',
},
{ text: 'Virtual Array', link: '/nativescript-core/virtual-array' },
{ text: 'File System', link: '/nativescript-core/file-system' },
{ text: 'Fps Meter', link: '/nativescript-core/fps-meter' },
//{ text: 'Observable', link: '/nativescript-core/observable' },
//{text: 'Observable Array',link: '/nativescript-core/observable-array'},
//{ text: 'Virtual Array', link: '/nativescript-core/virtual-array' },
//{ text: 'File System', link: '/nativescript-core/file-system' },
//{ text: 'Fps Meter', link: '/nativescript-core/fps-meter' },
{ text: 'Http', link: '/nativescript-core/http' },
{ text: 'Image Source', link: '/nativescript-core/image-source' },
{ text: 'Platform', link: '/nativescript-core/platform' },
{ text: 'Timer', link: '/nativescript-core/timer' },
{ text: 'Trace', link: '/nativescript-core/trace' },
{ text: 'Xml Parser', link: '/nativescript-core/xml-parser' },
//{ text: 'Image Source', link: '/nativescript-core/image-source' },
//{ text: 'Platform', link: '/nativescript-core/platform' },
//{ text: 'Timer', link: '/nativescript-core/timer' },
//{ text: 'Trace', link: '/nativescript-core/trace' },
//{ text: 'Xml Parser', link: '/nativescript-core/xml-parser' },
],
},
// {
Expand Down
104 changes: 104 additions & 0 deletions nativescript-core/Application.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
title: Application
---

## Application

The Application module provides abstraction over the platform-specific Application implementations. The module lets you manage the lifecycle of your NativeScript applications from starting the application to handling application events and creating platform-specific logic, such as, sending Broadcasts on Android or adding a Notification observer on IOS.

#### Usage

/// flavor javascript

```javascript
const applicationModule = require('@nativescript/core/application')
```

///

/// flavor typescript

```typescript
import { Application } from '@nativescript/core'
```

///

## Android

The application module provides a number of Android specific properties to access the Android app, context and activities.

/// flavor javascript

```javascript
const androidApp = applicationModule.android
const isPaused = androidApp.paused // e.g. false
const packageName = androidApp.packageName // The package ID e.g. org.nativescript.nativescriptsdkexamplesng
const nativeApp = androidApp.nativeApp // The native APplication reference
const foregroundActivity = androidApp.foregroundActivity // The current Activity reference
const context = androidApp.context // The current Android context
```

///

/// flavor typescript

```typescript

```

///

#### Registering a Broadcast Receiver

/// flavor javascript

```javascript
if (applicationModule.isAndroid) {
// use tns-platform-declarations to acces native APIs (e.g. android.content.Intent)
const receiverCallback = (androidContext, intent) => {
const level = intent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, -1)
const scale = intent.getIntExtra(android.os.BatteryManager.EXTRA_SCALE, -1)
const percent = (level / scale) * 100.0
vm.set('batteryLife', percent.toString())
}

applicationModule.android.registerBroadcastReceiver(
android.content.Intent.ACTION_BATTERY_CHANGED,
receiverCallback
)
}
```

///

/// flavor typescript

```typescript

```

///

#### Methods

| Name | Type | Description |
| ---------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `getConnectionType` | `number` | Gets the type of connection. Returns a value from the `connectivityModule.connectionType` enumeration. To use this method on Android you need to have the **android.permission.ACCESS_NETWORK_STATE** permission added to the **AndroidManifest.xml** file. |
| `startMonitoring(connectionTypeChangedCallback: function)` | `void` | Starts monitoring the connection type. |
| `stopMonitoring` | `void` | Stops monitoring the connection type. |

#### Connection Types

- `none = 0`,
- `wifi = 1`,
- `mobile = 2`,
- `ethernet = 3`,
- `bluetooth = 4`,
- `vpn = 5`

#### Native Component

| Android | iOS |
| :---------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |
| [CONNECTIVITY_SERVICE (android.content.Context)](https://developer.android.com/reference/android/content/Context) | [SCNetworkReachability](https://developer.apple.com/documentation/systemconfiguration/scnetworkreachability-g7d) |
7 changes: 0 additions & 7 deletions nativescript-core/connectivity.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ export function onNavigatedTo(args) {
- `bluetooth = 4`,
- `vpn = 5`

#### API References

| Name | Type |
| --------------------------------------------------------------------------- | -------- |
| [@nativescript/core/connectivity](/api-reference/modules.html#connectivity) | `Module` |
| [connectionType](/api-reference/modules.html#connectivity) | `Enum` |

#### Native Component

| Android | iOS |
Expand Down
6 changes: 0 additions & 6 deletions nativescript-core/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,3 @@ Http.request({
| `getJSON<T>(url: string): Promise<T>` | `Promise<T>` | Downloads the content from the specified URL as a string and returns its JSON.parse representation. |
| `getString(url: string): Promise<string>` | `Promise<string>` | Downloads the content from the specified URL as a string. |
| `request(options: HttpRequestOptions): Promise<HttpResponse>` | `Promise<HttpResponse>` | Makes a generic http request using the provided options and returns a HttpResponse Object. |

#### API References

| Name | Type |
| ---------------------------------------------------------------------------------------- | -------- |
| [@nativescript/core/http](https://docs.nativescript.org/api-reference/modules.html#http) | `Module` |

0 comments on commit 469929d

Please sign in to comment.