Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #2647 from StimulatingSolutions/InitOptions-cleanup
Browse files Browse the repository at this point in the history
update to InitOptions type definitions and related API docs
  • Loading branch information
fredgalvao authored Dec 9, 2018
2 parents ee4e8c8 + 20b4ffc commit e5370c4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 28 deletions.
36 changes: 18 additions & 18 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,25 @@ All available option attributes are described bellow. Currently, there are no Wi

#### Android

| Attribute | Type | Default | Description |
| ---------------------------- | --------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `android.icon` | `string` | | Optional. The name of a drawable resource to use as the small-icon. The name should not include the extension. |
| `android.iconColor` | `string` | | Optional. Sets the background color of the small icon on Android 5.0 and greater. [Supported Formats](<http://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String)>) |
| `android.sound` | `boolean` | `true` | Optional. If `true` it plays the sound specified in the push data or the default system sound. |
| `android.vibrate` | `boolean` | `true` | Optional. If `true` the device vibrates on receipt of notification. |
| `android.clearBadge` | `boolean` | `false` | Optional. If `true` the icon badge will be cleared on init and before push messages are processed. |
| `android.clearNotifications` | `boolean` | `true` | Optional. If `true` the app clears all pending notifications when it is closed. |
| `android.forceShow` | `boolean` | `false` | Optional. Controls the behavior of the notification when app is in foreground. If `true` and app is in foreground, it will show a notification in the notification drawer, the same way as when the app is in background (and `on('notification')` callback will be called _only when the user clicks the notification_). When `false` and app is in foreground, the `on('notification')` callback will be called immediately. |
| `android.topics` | `array` | `[]` | Optional. If the array contains one or more strings each string will be used to subscribe to a FcmPubSub topic. |
| `android.messageKey` | `string` | `message` | Optional. The key to search for text of notification. |
| `android.titleKey` | `string` | `'title'` | Optional. The key to search for title of notification. |
| Attribute | Type | Default | Description |
| ---------------------------- | --------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `android.icon` | `string` | | Optional. The name of a drawable resource to use as the small-icon. The name should not include the extension. |
| `android.iconColor` | `string` | | Optional. Sets the background color of the small icon on Android 5.0 and greater. [Supported Formats](<http://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String)>) |
| `android.sound` | `boolean` | `true` | Optional. If `true` it plays the sound specified in the push data or the default system sound. |
| `android.vibrate` | `boolean` | `true` | Optional. If `true` the device vibrates on receipt of notification. |
| `android.clearBadge` | `boolean` | `false` | Optional. If `true` the icon badge will be cleared on init and before push messages are processed. |
| `android.clearNotifications` | `boolean` | `true` | Optional. If `true` the app clears all pending notifications when it is closed. |
| `android.forceShow` | `boolean` | `false` | Optional. Controls the behavior of the notification when app is in foreground. If `true` and app is in foreground, it will show a notification in the notification drawer, the same way as when the app is in background (and `on('notification')` callback will be called _only when the user clicks the notification_). When `false` and app is in foreground, the `on('notification')` callback will be called immediately. |
| `android.topics` | `array` | `[]` | Optional. If the array contains one or more strings each string will be used to subscribe to a FcmPubSub topic. |
| `android.messageKey` | `string` | `'message'` | Optional. The key to search for text of notification. |
| `android.titleKey` | `string` | `'title'` | Optional. The key to search for title of notification. |

#### Browser

| Attribute | Type | Default | Description |
| ------------------------------ | -------- | ------------------------------------------------------------ | -------------------------------------------------- |
| `browser.pushServiceURL` | `string` | `http://push.api.phonegap.com/v1/push` | Optional. URL for the push server you want to use. |
| `browser.applicationServerKey` | `string` | `` | Optional. Your GCM API key if you are using VAPID keys. |
| Attribute | Type | Default | Description |
| ------------------------------ | -------- | ------------------------------------------------------------ | ------------------------------------------------------- |
| `browser.pushServiceURL` | `string` | `http://push.api.phonegap.com/v1/push` | Optional. URL for the push server you want to use. |
| `browser.applicationServerKey` | `string` | | Optional. Your GCM API key if you are using VAPID keys. |

#### iOS

Expand All @@ -72,7 +72,7 @@ All iOS boolean options can also be specified as `string`
| `ios.badge` | `boolean` | `false` | Optional. If `true` the device sets the badge number on receipt of notification. **Note:** the value you set this option to the first time you call the init method will be how the application always acts. Once this is set programmatically in the init method it can only be changed manually by the user in Settings>Notifications>`App Name`. This is normal iOS behaviour. |
| `ios.sound` | `boolean` | `false` | Optional. If `true` the device plays a sound on receipt of notification. **Note:** the value you set this option to the first time you call the init method will be how the application always acts. Once this is set programmatically in the init method it can only be changed manually by the user in Settings>Notifications>`App Name`. This is normal iOS behaviour. |
| `ios.clearBadge` | `boolean` | `false` | Optional. If `true` the badge will be cleared on app startup. |
| `ios.categories` | `Object` | `{}` | Optional. The data required in order to enabled Action Buttons for iOS. See [Action Buttons on iOS](https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#action-buttons-1) for more details. |
| `ios.categories` | `Object` | `{}` | Optional. The data required in order to enable Action Buttons for iOS. See [Action Buttons on iOS](https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#action-buttons-1) for more details. |

#### iOS GCM support

Expand Down Expand Up @@ -108,7 +108,7 @@ This type of notifications consist only of payload data, so the developer is the

In order to use the VoIP Notifications, you have to create a VoIP Services Certificate. There are a lot of tutorials on the web to achieve this. Once created, you must use this certificate in order to communicate with the APN Service.

To set up the VoIP Notification in ios do:
To set up the VoIP Notification in iOS do:

```javascript
const push = PushNotification.init({
Expand Down
44 changes: 34 additions & 10 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ declare namespace PhonegapPluginPush {
* Android specific initialization options.
*/
android?: {
/**
* Maps to the project number in the Google Developer Console.
*/
senderID: string
/**
* The name of a drawable resource to use as the small-icon. The name should not include the extension.
*/
Expand All @@ -141,6 +137,10 @@ declare namespace PhonegapPluginPush {
* If true the device vibrates on receipt of notification. Default is true.
*/
vibrate?: boolean
/**
* If true the icon badge will be cleared on init and before push messages are processed. Default is false.
*/
clearBadge?: boolean
/**
* If true the app clears all pending notifications when it is closed. Default is true.
*/
Expand All @@ -153,12 +153,40 @@ declare namespace PhonegapPluginPush {
* If the array contains one or more strings each string will be used to subscribe to a GcmPubSub topic.
*/
topics?: string[]
/**
* The key to search for text of notification. Default is 'message'.
*/
messageKey?: string
/**
* The key to search for title of notification. Default is 'title'.
*/
titleKey?: string
}

/**
* Browser specific initialization options.
*/
browser?: {
/**
* URL for the push server you want to use. Default is 'http://push.api.phonegap.com/v1/push'.
*/
pushServiceURL?: string
/**
* Your GCM API key if you are using VAPID keys.
*/
applicationServerKey?: string
}

/**
* iOS specific initialization options.
*/
ios?: {
/**
* If true|"true" the device will be set up to receive VoIP Push notifications and the other options will be ignored
* since VoIP notifications are silent notifications that should be handled in the "notification" event.
* Default is false|"false".
*/
voip?: boolean | string
/**
* If true|"true" the device sets the badge number on receipt of notification.
* Default is false|"false".
Expand All @@ -184,24 +212,20 @@ declare namespace PhonegapPluginPush {
*/
alert?: boolean | string
/**
* If true|"true" the badge will be cleared on app startup. Default is false|"false".
* If true|"true" the badge will be cleared on app startup. Defaults to false|"false".
*/
clearBadge?: boolean | string
/**
* The data required in order to enable Action Buttons for iOS.
* Action Buttons on iOS - https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#action-buttons-1
*/
categories?: CategoryArray
/**
* Maps to the project number in the Google Developer Console. Setting this uses GCM for notifications instead of native
*/
senderID?: string
/**
* Whether to use prod or sandbox GCM setting. Defaults to false.
*/
fcmSandbox?: boolean
/**
* If the array contains one or more strings each string will be used to subscribe to a GcmPubSub topic. Note: only usable in conjunction with senderID
* If the array contains one or more strings each string will be used to subscribe to a FcmPubSub topic. Defaults to [].
*/
topics?: string[]
}
Expand Down

0 comments on commit e5370c4

Please sign in to comment.