Skip to content

Commit

Permalink
feat(push-notifications): Add new type for registrationError (#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Mar 1, 2022
1 parent 2018f78 commit e5e78bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
17 changes: 12 additions & 5 deletions push-notifications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,17 +363,17 @@ Provides the push notification token.
### addListener('registrationError', ...)

```typescript
addListener(eventName: 'registrationError', listenerFunc: (error: any) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
addListener(eventName: 'registrationError', listenerFunc: (error: RegistrationError) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
```

Called when the push notification registration finished with problems.

Provides an error with the registration problem.

| Param | Type |
| ------------------ | ------------------------------------ |
| **`eventName`** | <code>'registrationError'</code> |
| **`listenerFunc`** | <code>(error: any) =&gt; void</code> |
| Param | Type |
| ------------------ | ----------------------------------------------------------------------------------- |
| **`eventName`** | <code>'registrationError'</code> |
| **`listenerFunc`** | <code>(error: <a href="#registrationerror">RegistrationError</a>) =&gt; void</code> |

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

Expand Down Expand Up @@ -505,6 +505,13 @@ Remove all native listeners for this plugin.
| **`value`** | <code>string</code> | On iOS it contains the APNS token. On Android it contains the FCM token. | 1.0.0 |


#### RegistrationError

| Prop | Type | Description | Since |
| ----------- | ------------------- | -------------------------------------------------- | ----- |
| **`error`** | <code>string</code> | Error message describing the registration failure. | 2.0.0 |


#### ActionPerformed

| Prop | Type | Description | Since |
Expand Down
11 changes: 10 additions & 1 deletion push-notifications/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export interface PushNotificationsPlugin {
*/
addListener(
eventName: 'registrationError',
listenerFunc: (error: any) => void,
listenerFunc: (error: RegistrationError) => void,
): Promise<PluginListenerHandle> & PluginListenerHandle;

/**
Expand Down Expand Up @@ -292,6 +292,15 @@ export interface Token {
value: string;
}

export interface RegistrationError {
/**
* Error message describing the registration failure.
*
* @since 2.0.0
*/
error: string;
}

export interface DeliveredNotifications {
/**
* List of notifications that are visible on the
Expand Down

0 comments on commit e5e78bb

Please sign in to comment.