Skip to content

Commit

Permalink
fix: Use the event names from Capacitor 2 (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Jan 26, 2021
1 parent 26500a0 commit 008fe9e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions local-notifications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ npx cap sync
* [`listChannels()`](#listchannels)
* [`checkPermissions()`](#checkpermissions)
* [`requestPermissions()`](#requestpermissions)
* [`addListener('received', ...)`](#addlistenerreceived-)
* [`addListener('actionPerformed', ...)`](#addlisteneractionperformed-)
* [`addListener('localNotificationReceived', ...)`](#addlistenerlocalnotificationreceived-)
* [`addListener('localNotificationActionPerformed', ...)`](#addlistenerlocalnotificationactionperformed-)
* [`removeAllListeners()`](#removealllisteners)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
Expand Down Expand Up @@ -204,17 +204,17 @@ Request permission to display local notifications.
--------------------


### addListener('received', ...)
### addListener('localNotificationReceived', ...)

```typescript
addListener(eventName: 'received', listenerFunc: (notification: LocalNotificationSchema) => void) => PluginListenerHandle
addListener(eventName: 'localNotificationReceived', listenerFunc: (notification: LocalNotificationSchema) => void) => PluginListenerHandle
```

Listen for when notifications are displayed.

| Param | Type |
| ------------------ | ------------------------------------------------------------------------------------------------------ |
| **`eventName`** | <code>'received'</code> |
| **`eventName`** | <code>'localNotificationReceived'</code> |
| **`listenerFunc`** | <code>(notification: <a href="#localnotificationschema">LocalNotificationSchema</a>) =&gt; void</code> |

**Returns:** <code><a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
Expand All @@ -224,17 +224,17 @@ Listen for when notifications are displayed.
--------------------


### addListener('actionPerformed', ...)
### addListener('localNotificationActionPerformed', ...)

```typescript
addListener(eventName: 'actionPerformed', listenerFunc: (notificationAction: ActionPerformed) => void) => PluginListenerHandle
addListener(eventName: 'localNotificationActionPerformed', listenerFunc: (notificationAction: ActionPerformed) => void) => PluginListenerHandle
```

Listen for when an action is performed on a notification.

| Param | Type |
| ------------------ | -------------------------------------------------------------------------------------------- |
| **`eventName`** | <code>'actionPerformed'</code> |
| **`eventName`** | <code>'localNotificationActionPerformed'</code> |
| **`listenerFunc`** | <code>(notificationAction: <a href="#actionperformed">ActionPerformed</a>) =&gt; void</code> |

**Returns:** <code><a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected void handleOnNewIntent(Intent data) {
}
JSObject dataJson = manager.handleNotificationActionPerformed(data, notificationStorage);
if (dataJson != null) {
notifyListeners("actionPerformed", dataJson, true);
notifyListeners("localNotificationActionPerformed", dataJson, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class LocalNotificationsHandler: NSObject, NotificationHandlerProtocol {
public func willPresent(notification: UNNotification) -> UNNotificationPresentationOptions {
let notificationData = makeNotificationRequestJSObject(notification.request)

self.plugin?.notifyListeners("received", data: notificationData)
self.plugin?.notifyListeners("localNotificationReceived", data: notificationData)

if let options = notificationRequestLookup[notification.request.identifier] {
let silent = options["silent"] as? Bool ?? false
Expand Down Expand Up @@ -66,7 +66,7 @@ public class LocalNotificationsHandler: NSObject, NotificationHandlerProtocol {

data["notification"] = makeNotificationRequestJSObject(originalNotificationRequest)

self.plugin?.notifyListeners("actionPerformed", data: data, retainUntilConsumed: true)
self.plugin?.notifyListeners("localNotificationActionPerformed", data: data, retainUntilConsumed: true)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions local-notifications/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export interface LocalNotificationsPlugin {
* @since 1.0.0
*/
addListener(
eventName: 'received',
eventName: 'localNotificationReceived',
listenerFunc: (notification: LocalNotificationSchema) => void,
): PluginListenerHandle;

Expand All @@ -139,7 +139,7 @@ export interface LocalNotificationsPlugin {
* @since 1.0.0
*/
addListener(
eventName: 'actionPerformed',
eventName: 'localNotificationActionPerformed',
listenerFunc: (notificationAction: ActionPerformed) => void,
): PluginListenerHandle;

Expand Down

0 comments on commit 008fe9e

Please sign in to comment.