Skip to content

Commit

Permalink
docs(push-notifications): Add missing information on types (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed Jun 25, 2021
1 parent 3479783 commit 1020eed
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 31 deletions.
72 changes: 42 additions & 30 deletions push-notifications/README.md
Expand Up @@ -260,6 +260,10 @@ checkPermissions() => Promise<PermissionStatus>

Check permission to receive push notifications.

On Android the status is always granted because you can always
receive push notifications. If you need to check if the user allows
to display notifications, use local-notifications plugin.

**Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>

**Since:** 1.0.0
Expand All @@ -275,6 +279,14 @@ requestPermissions() => Promise<PermissionStatus>

Request permission to receive push notifications.

On Android it doesn't prompt for permission because you can always
receive push notifications.

On iOS, the first time you use the function, it will prompt the user
for push notification permission and return granted or denied based
on the user selection. On following calls it will currect status of
the permission without prompting again.

**Returns:** <code>Promise&lt;<a href="#permissionstatus">PermissionStatus</a>&gt;</code>

**Since:** 1.0.0
Expand Down Expand Up @@ -384,26 +396,26 @@ Remove all native listeners for this plugin.

#### DeliveredNotifications

| Prop | Type | Since |
| ------------------- | ------------------------------------- | ----- |
| **`notifications`** | <code>PushNotificationSchema[]</code> | 1.0.0 |
| Prop | Type | Description | Since |
| ------------------- | ------------------------------------- | ------------------------------------------------------------------- | ----- |
| **`notifications`** | <code>PushNotificationSchema[]</code> | List of notifications that are visible on the notifications screen. | 1.0.0 |


#### PushNotificationSchema

| Prop | Type | Description | Since |
| ------------------ | -------------------- | ------------------------------------------------------------------------------------------------------------------- | ----- |
| **`title`** | <code>string</code> | The notification title. | 1.0.0 |
| **`subtitle`** | <code>string</code> | The notification subtitle. | 1.0.0 |
| **`body`** | <code>string</code> | The main text payload for the notification. | 1.0.0 |
| **`id`** | <code>string</code> | The notification identifier. | 1.0.0 |
| **`badge`** | <code>number</code> | The number to display for the app icon badge. | 1.0.0 |
| **`notification`** | <code>any</code> | | 1.0.0 |
| **`data`** | <code>any</code> | | 1.0.0 |
| **`click_action`** | <code>string</code> | | 1.0.0 |
| **`link`** | <code>string</code> | | 1.0.0 |
| **`group`** | <code>string</code> | Set the group identifier for notification grouping Only available on Android. Works like `threadIdentifier` on iOS. | 1.0.0 |
| **`groupSummary`** | <code>boolean</code> | Designate this notification as the summary for an associated `group`. Only available on Android. | 1.0.0 |
| Prop | Type | Description | Since |
| ------------------ | -------------------- | -------------------------------------------------------------------------------------------------------------------- | ----- |
| **`title`** | <code>string</code> | The notification title. | 1.0.0 |
| **`subtitle`** | <code>string</code> | The notification subtitle. | 1.0.0 |
| **`body`** | <code>string</code> | The main text payload for the notification. | 1.0.0 |
| **`id`** | <code>string</code> | The notification identifier. | 1.0.0 |
| **`badge`** | <code>number</code> | The number to display for the app icon badge. | 1.0.0 |
| **`notification`** | <code>any</code> | It's not being returned. | 1.0.0 |
| **`data`** | <code>any</code> | Any additional data that was included in the push notification payload. | 1.0.0 |
| **`click_action`** | <code>string</code> | The action to be performed on the user opening the notification. Only available on Android. | 1.0.0 |
| **`link`** | <code>string</code> | Deep link from the notification. Only available on Android. | 1.0.0 |
| **`group`** | <code>string</code> | Set the group identifier for notification grouping. Only available on Android. Works like `threadIdentifier` on iOS. | 1.0.0 |
| **`groupSummary`** | <code>boolean</code> | Designate this notification as the summary for an associated `group`. Only available on Android. | 1.0.0 |


#### Channel
Expand All @@ -423,16 +435,16 @@ Remove all native listeners for this plugin.

#### ListChannelsResult

| Prop | Type | Since |
| -------------- | ---------------------- | ----- |
| **`channels`** | <code>Channel[]</code> | 1.0.0 |
| Prop | Type | Description | Since |
| -------------- | ---------------------- | --------------------------------------------- | ----- |
| **`channels`** | <code>Channel[]</code> | List of all the Channels created by your app. | 1.0.0 |


#### PermissionStatus

| Prop | Type | Since |
| ------------- | ----------------------------------------------------------- | ----- |
| **`receive`** | <code><a href="#permissionstate">PermissionState</a></code> | 1.0.0 |
| Prop | Type | Description | Since |
| ------------- | ----------------------------------------------------------- | -------------------------------------------- | ----- |
| **`receive`** | <code><a href="#permissionstate">PermissionState</a></code> | Permission state of receiving notifications. | 1.0.0 |


#### PluginListenerHandle
Expand All @@ -444,18 +456,18 @@ Remove all native listeners for this plugin.

#### Token

| Prop | Type | Since |
| ----------- | ------------------- | ----- |
| **`value`** | <code>string</code> | 1.0.0 |
| Prop | Type | Description | Since |
| ----------- | ------------------- | ------------------------------------------------------------------------ | ----- |
| **`value`** | <code>string</code> | On iOS it contains the APNS token. On Android it contains the FCM token. | 1.0.0 |


#### ActionPerformed

| Prop | Type | Since |
| ------------------ | ------------------------------------------------------------------------- | ----- |
| **`actionId`** | <code>string</code> | 1.0.0 |
| **`inputValue`** | <code>string</code> | 1.0.0 |
| **`notification`** | <code><a href="#pushnotificationschema">PushNotificationSchema</a></code> | 1.0.0 |
| Prop | Type | Description | Since |
| ------------------ | ------------------------------------------------------------------------- | --------------------------------------------------------------- | ----- |
| **`actionId`** | <code>string</code> | The action performed on the notification. | 1.0.0 |
| **`inputValue`** | <code>string</code> | Text entered on the notification action. Only available on iOS. | 1.0.0 |
| **`notification`** | <code><a href="#pushnotificationschema">PushNotificationSchema</a></code> | The notification in which the action was performed. | 1.0.0 |


### Type Aliases
Expand Down
46 changes: 45 additions & 1 deletion push-notifications/src/definitions.ts
Expand Up @@ -93,13 +93,25 @@ export interface PushNotificationsPlugin {
/**
* Check permission to receive push notifications.
*
* On Android the status is always granted because you can always
* receive push notifications. If you need to check if the user allows
* to display notifications, use local-notifications plugin.
*
* @since 1.0.0
*/
checkPermissions(): Promise<PermissionStatus>;

/**
* Request permission to receive push notifications.
*
* On Android it doesn't prompt for permission because you can always
* receive push notifications.
*
* On iOS, the first time you use the function, it will prompt the user
* for push notification permission and return granted or denied based
* on the user selection. On following calls it will currect status of
* the permission without prompting again.
*
* @since 1.0.0
*/
requestPermissions(): Promise<PermissionStatus>;
Expand Down Expand Up @@ -193,27 +205,41 @@ export interface PushNotificationSchema {
badge?: number;

/**
* It's not being returned.
*
* @deprecated will be removed in next major version.
* @since 1.0.0
*/
notification?: any;

/**
* Any additional data that was included in the
* push notification payload.
*
* @since 1.0.0
*/
data: any;

/**
* The action to be performed on the user opening the notification.
*
* Only available on Android.
*
* @since 1.0.0
*/
click_action?: string;

/**
* Deep link from the notification.
*
* Only available on Android.
*
* @since 1.0.0
*/
link?: string;

/**
* Set the group identifier for notification grouping
* Set the group identifier for notification grouping.
*
* Only available on Android. Works like `threadIdentifier` on iOS.
*
Expand All @@ -233,30 +259,44 @@ export interface PushNotificationSchema {

export interface ActionPerformed {
/**
* The action performed on the notification.
*
* @since 1.0.0
*/
actionId: string;

/**
* Text entered on the notification action.
*
* Only available on iOS.
*
* @since 1.0.0
*/
inputValue?: string;

/**
* The notification in which the action was performed.
*
* @since 1.0.0
*/
notification: PushNotificationSchema;
}

export interface Token {
/**
* On iOS it contains the APNS token.
* On Android it contains the FCM token.
*
* @since 1.0.0
*/
value: string;
}

export interface DeliveredNotifications {
/**
* List of notifications that are visible on the
* notifications screen.
*
* @since 1.0.0
*/
notifications: PushNotificationSchema[];
Expand Down Expand Up @@ -348,13 +388,17 @@ export type Visibility = -1 | 0 | 1;

export interface ListChannelsResult {
/**
* List of all the Channels created by your app.
*
* @since 1.0.0
*/
channels: Channel[];
}

export interface PermissionStatus {
/**
* Permission state of receiving notifications.
*
* @since 1.0.0
*/
receive: PermissionState;
Expand Down

0 comments on commit 1020eed

Please sign in to comment.