@capacitor/app
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -6,2 +6,14 @@ # Change Log | ||
## [0.1.1](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/app@0.1.0...@capacitor/app@0.1.1) (2020-12-20) | ||
### Bug Fixes | ||
* support deprecated types from Capacitor 2 ([#139](https://github.com/ionic-team/capacitor-plugins/issues/139)) ([2d7127a](https://github.com/ionic-team/capacitor-plugins/commit/2d7127a488e26f0287951921a6db47c49d817336)) | ||
* **app:** remove iOS deprecate warnings ([#121](https://github.com/ionic-team/capacitor-plugins/issues/121)) ([d009826](https://github.com/ionic-team/capacitor-plugins/commit/d009826ded4a948041586bcc4d8a0fa51afbea5f)) | ||
# 0.1.0 (2020-12-02) | ||
@@ -8,0 +20,0 @@ |
@@ -42,3 +42,3 @@ import type { PluginListenerHandle } from '@capacitor/core'; | ||
} | ||
export interface AppUrlOpen { | ||
export interface URLOpenListenerEvent { | ||
/** | ||
@@ -74,3 +74,3 @@ * The URL the app was opened with. | ||
} | ||
export interface AppRestoredResult { | ||
export interface RestoredListenerEvent { | ||
/** | ||
@@ -110,2 +110,6 @@ * The pluginId this result corresponds to. For example, `Camera`. | ||
} | ||
export declare type StateChangeListener = (state: AppState) => void; | ||
export declare type URLOpenListener = (event: URLOpenListenerEvent) => void; | ||
export declare type RestoredListener = (event: RestoredListenerEvent) => void; | ||
export declare type BackButtonListener = () => void; | ||
export interface AppPlugin { | ||
@@ -144,3 +148,3 @@ /** | ||
*/ | ||
addListener(eventName: 'appStateChange', listenerFunc: (state: AppState) => void): PluginListenerHandle; | ||
addListener(eventName: 'appStateChange', listenerFunc: StateChangeListener): PluginListenerHandle; | ||
/** | ||
@@ -152,3 +156,3 @@ * Listen for url open events for the app. This handles both custom URL scheme links as well | ||
*/ | ||
addListener(eventName: 'appUrlOpen', listenerFunc: (data: AppUrlOpen) => void): PluginListenerHandle; | ||
addListener(eventName: 'appUrlOpen', listenerFunc: URLOpenListener): PluginListenerHandle; | ||
/** | ||
@@ -159,5 +163,23 @@ * If the app was launched with previously persisted plugin call data, such as on Android | ||
* | ||
* On Android, due to memory constraints on low-end devices, it's possible | ||
* that, if your app launches a new activity, your app will be terminated by | ||
* the operating system in order to reduce memory consumption. | ||
* | ||
* For example, that means the Camera API, which launches a new Activity to | ||
* take a photo, may not be able to return data back to your app. | ||
* | ||
* To avoid this, Capacitor stores all restored activity results on launch. | ||
* You should add a listener for `appRestoredResult` in order to handle any | ||
* plugin call results that were delivered when your app was not running. | ||
* | ||
* Once you have that result (if any), you can update the UI to restore a | ||
* logical experience for the user, such as navigating or selecting the | ||
* proper tab. | ||
* | ||
* We recommend every Android app using plugins that rely on external | ||
* Activities (for example, Camera) to have this event and process handled. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
addListener(eventName: 'appRestoredResult', listenerFunc: (data: AppRestoredResult) => void): PluginListenerHandle; | ||
addListener(eventName: 'appRestoredResult', listenerFunc: RestoredListener): PluginListenerHandle; | ||
/** | ||
@@ -170,3 +192,3 @@ * Listen for the hardware back button event (Android only). Listening for this event will disable the | ||
*/ | ||
addListener(eventName: 'backButton', listenerFunc: () => void): PluginListenerHandle; | ||
addListener(eventName: 'backButton', listenerFunc: BackButtonListener): PluginListenerHandle; | ||
/** | ||
@@ -179,1 +201,11 @@ * Remove all native listeners for this plugin | ||
} | ||
/** | ||
* @deprecated Use `RestoredListenerEvent`. | ||
* @since 1.0.0 | ||
*/ | ||
export declare type AppRestoredResult = RestoredListenerEvent; | ||
/** | ||
* @deprecated Use `URLOpenListenerEvent`. | ||
* @since 1.0.0 | ||
*/ | ||
export declare type AppUrlOpen = URLOpenListenerEvent; |
import type { AppPlugin } from './definitions'; | ||
declare const App: AppPlugin; | ||
export * from './definitions'; | ||
export { App }; |
@@ -5,3 +5,4 @@ import { registerPlugin } from '@capacitor/core'; | ||
}); | ||
export * from './definitions'; | ||
export { App }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@capacitor/app", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "The App API handles high level App state and events.For example, this API emits events when the app enters and leaves the foreground, handles deeplinks, opens other apps, and manages persisted plugin state.", | ||
@@ -46,6 +46,6 @@ "main": "dist/esm/index.js", | ||
"devDependencies": { | ||
"@capacitor/android": "^3.0.0-alpha.7", | ||
"@capacitor/core": "^3.0.0-alpha.7", | ||
"@capacitor/docgen": "^0.0.10", | ||
"@capacitor/ios": "^3.0.0-alpha.7", | ||
"@capacitor/android": "^3.0.0-alpha.10", | ||
"@capacitor/core": "^3.0.0-alpha.9", | ||
"@capacitor/docgen": "0.0.14", | ||
"@capacitor/ios": "^3.0.0-alpha.9", | ||
"@ionic/eslint-config": "^0.3.0", | ||
@@ -63,3 +63,3 @@ "@ionic/prettier-config": "~1.0.1", | ||
"peerDependencies": { | ||
"@capacitor/core": "^3.0.0-alpha.6" | ||
"@capacitor/core": "^3.0.0-alpha.9" | ||
}, | ||
@@ -82,3 +82,3 @@ "prettier": "@ionic/prettier-config", | ||
}, | ||
"gitHead": "78c1981920988ec84c17bbc61b1da1df9743571c" | ||
"gitHead": "481260d148b920b85755dd5f9b65df0bb0db4244" | ||
} |
126
README.md
@@ -12,2 +12,26 @@ # @capacitor/app | ||
## Example | ||
```typescript | ||
import { App } from '@capacitor/app'; | ||
App.addListener('appStateChange', ({ isActive }) => { | ||
console.log('App state changed. Is active?', isActive); | ||
}); | ||
App.addListener('appUrlOpen', data => { | ||
console.log('App opened with URL:', data); | ||
}); | ||
App.addListener('appRestoredResult', data => { | ||
console.log('Restored state:', data); | ||
}); | ||
const checkAppLaunchUrl = async () => { | ||
const { url } = await App.getLaunchUrl(); | ||
alert('App opened with URL: ' + url); | ||
}; | ||
``` | ||
## API | ||
@@ -21,8 +45,9 @@ | ||
* [`getLaunchUrl()`](#getlaunchurl) | ||
* [`addListener(...)`](#addlistener) | ||
* [`addListener(...)`](#addlistener) | ||
* [`addListener(...)`](#addlistener) | ||
* [`addListener(...)`](#addlistener) | ||
* [`addListener('appStateChange', ...)`](#addlistenerappstatechange-) | ||
* [`addListener('appUrlOpen', ...)`](#addlistenerappurlopen-) | ||
* [`addListener('appRestoredResult', ...)`](#addlistenerapprestoredresult-) | ||
* [`addListener('backButton', ...)`](#addlistenerbackbutton-) | ||
* [`removeAllListeners()`](#removealllisteners) | ||
* [Interfaces](#interfaces) | ||
* [Type Aliases](#type-aliases) | ||
@@ -97,6 +122,6 @@ </docgen-index> | ||
### addListener(...) | ||
### addListener('appStateChange', ...) | ||
```typescript | ||
addListener(eventName: 'appStateChange', listenerFunc: (state: AppState) => void) => PluginListenerHandle | ||
addListener(eventName: 'appStateChange', listenerFunc: StateChangeListener) => PluginListenerHandle | ||
``` | ||
@@ -106,6 +131,6 @@ | ||
| Param | Type | | ||
| ------------------ | ----------------------------------------------------------------- | | ||
| **`eventName`** | <code>"appStateChange"</code> | | ||
| **`listenerFunc`** | <code>(state: <a href="#appstate">AppState</a>) => void</code> | | ||
| Param | Type | | ||
| ------------------ | ------------------------------------------------------------------- | | ||
| **`eventName`** | <code>'appStateChange'</code> | | ||
| **`listenerFunc`** | <code><a href="#statechangelistener">StateChangeListener</a></code> | | ||
@@ -119,6 +144,6 @@ **Returns:** <code><a href="#pluginlistenerhandle">PluginListenerHandle</a></code> | ||
### addListener(...) | ||
### addListener('appUrlOpen', ...) | ||
```typescript | ||
addListener(eventName: 'appUrlOpen', listenerFunc: (data: AppUrlOpen) => void) => PluginListenerHandle | ||
addListener(eventName: 'appUrlOpen', listenerFunc: URLOpenListener) => PluginListenerHandle | ||
``` | ||
@@ -129,6 +154,6 @@ | ||
| Param | Type | | ||
| ------------------ | -------------------------------------------------------------------- | | ||
| **`eventName`** | <code>"appUrlOpen"</code> | | ||
| **`listenerFunc`** | <code>(data: <a href="#appurlopen">AppUrlOpen</a>) => void</code> | | ||
| Param | Type | | ||
| ------------------ | ----------------------------------------------------------- | | ||
| **`eventName`** | <code>'appUrlOpen'</code> | | ||
| **`listenerFunc`** | <code><a href="#urlopenlistener">URLOpenListener</a></code> | | ||
@@ -142,6 +167,6 @@ **Returns:** <code><a href="#pluginlistenerhandle">PluginListenerHandle</a></code> | ||
### addListener(...) | ||
### addListener('appRestoredResult', ...) | ||
```typescript | ||
addListener(eventName: 'appRestoredResult', listenerFunc: (data: AppRestoredResult) => void) => PluginListenerHandle | ||
addListener(eventName: 'appRestoredResult', listenerFunc: RestoredListener) => PluginListenerHandle | ||
``` | ||
@@ -153,7 +178,25 @@ | ||
| Param | Type | | ||
| ------------------ | ---------------------------------------------------------------------------------- | | ||
| **`eventName`** | <code>"appRestoredResult"</code> | | ||
| **`listenerFunc`** | <code>(data: <a href="#apprestoredresult">AppRestoredResult</a>) => void</code> | | ||
On Android, due to memory constraints on low-end devices, it's possible | ||
that, if your app launches a new activity, your app will be terminated by | ||
the operating system in order to reduce memory consumption. | ||
For example, that means the Camera API, which launches a new Activity to | ||
take a photo, may not be able to return data back to your app. | ||
To avoid this, Capacitor stores all restored activity results on launch. | ||
You should add a listener for `appRestoredResult` in order to handle any | ||
plugin call results that were delivered when your app was not running. | ||
Once you have that result (if any), you can update the UI to restore a | ||
logical experience for the user, such as navigating or selecting the | ||
proper tab. | ||
We recommend every Android app using plugins that rely on external | ||
Activities (for example, Camera) to have this event and process handled. | ||
| Param | Type | | ||
| ------------------ | ------------------------------------------------------------- | | ||
| **`eventName`** | <code>'appRestoredResult'</code> | | ||
| **`listenerFunc`** | <code><a href="#restoredlistener">RestoredListener</a></code> | | ||
**Returns:** <code><a href="#pluginlistenerhandle">PluginListenerHandle</a></code> | ||
@@ -166,6 +209,6 @@ | ||
### addListener(...) | ||
### addListener('backButton', ...) | ||
```typescript | ||
addListener(eventName: 'backButton', listenerFunc: () => void) => PluginListenerHandle | ||
addListener(eventName: 'backButton', listenerFunc: BackButtonListener) => PluginListenerHandle | ||
``` | ||
@@ -177,6 +220,6 @@ | ||
| Param | Type | | ||
| ------------------ | -------------------------- | | ||
| **`eventName`** | <code>"backButton"</code> | | ||
| **`listenerFunc`** | <code>() => void</code> | | ||
| Param | Type | | ||
| ------------------ | ----------------------------------------------------------------- | | ||
| **`eventName`** | <code>'backButton'</code> | | ||
| **`listenerFunc`** | <code><a href="#backbuttonlistener">BackButtonListener</a></code> | | ||
@@ -237,3 +280,3 @@ **Returns:** <code><a href="#pluginlistenerhandle">PluginListenerHandle</a></code> | ||
#### AppUrlOpen | ||
#### URLOpenListenerEvent | ||
@@ -247,3 +290,3 @@ | Prop | Type | Description | Since | | ||
#### AppRestoredResult | ||
#### RestoredListenerEvent | ||
@@ -258,2 +301,25 @@ | Prop | Type | Description | Since | | ||
### Type Aliases | ||
#### StateChangeListener | ||
<code>(state: <a href="#appstate">AppState</a>): void</code> | ||
#### URLOpenListener | ||
<code>(event: <a href="#urlopenlistenerevent">URLOpenListenerEvent</a>): void</code> | ||
#### RestoredListener | ||
<code>(event: <a href="#restoredlistenerevent">RestoredListenerEvent</a>): void</code> | ||
#### BackButtonListener | ||
<code>(): void</code> | ||
</docgen-api> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
41444
291
313
0
66
232645
36
9
302