Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.14.0

Adds the ability to replace a Push Notification you already sent with a new one.

## 1.13.0

Adds custom icons and interruption levels for Push Notifications. Set `icon` to show a service logo or avatar on the notification, and `interruption_level` to deliver it as `passive`, `active`, or `time-sensitive`.
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,24 @@ await activitysmith.notifications.send({
});
```

### Replace a Push Notification

Every send returns a `notification_id`. Pass it to `replace` to update a Push Notification you already sent, for example when an incident you alerted on is resolved. The replacement takes the old notification's place on the Lock Screen and in history instead of stacking a second one. It arrives silently, without sound or waking the screen, and goes to the same recipients as the original.

Omit `metadata` or `tags` to keep their stored values.

```js
const sent = await activitysmith.notifications.send({
title: "🚨 checkout-api is down",
message: "500 errors on 62% of requests.",
});

await activitysmith.notifications.replace(sent.notification_id, {
title: "✅ checkout-api recovered",
message: "Error rate is back to normal. Incident resolved.",
});
```

## Live Activities

Choose the Live Activity type that matches what you want to show:
Expand Down
65 changes: 63 additions & 2 deletions generated/apis/PushNotificationsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ import type {
BillingBlockedError,
ForbiddenError,
NoRecipientsError,
NotFoundError,
PushNotificationReplaceRequest,
PushNotificationReplaceResponse,
PushNotificationRequest,
PushNotificationResponse,
SendPushNotification429Response,
} from '../models/index';

export interface ReplacePushNotificationRequest {
notificationId: string;
pushNotificationReplaceRequest: PushNotificationReplaceRequest;
}

export interface SendPushNotificationRequest {
pushNotificationRequest: PushNotificationRequest;
}
Expand All @@ -34,7 +42,60 @@ export interface SendPushNotificationRequest {
export class PushNotificationsApi extends runtime.BaseAPI {

/**
* Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`. Optional `icon` shows a custom image, such as a service logo or avatar, next to a smaller app icon. Optional `interruption_level` sets how urgently iOS presents the notification. Optional tags to organize and filter notification history.
* Replaces a Push Notification you already sent, using the `notification_id` from the send response. The replacement takes the original\'s place on the Lock Screen and in Notification Center instead of appearing as a second notification. It is delivered silently, with no sound or screen wake, to the same recipients as the original. Notification history is updated in place.
* Replace a push notification
*/
async replacePushNotificationRaw(requestParameters: ReplacePushNotificationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<PushNotificationReplaceResponse>> {
if (requestParameters['notificationId'] == null) {
throw new runtime.RequiredError(
'notificationId',
'Required parameter "notificationId" was null or undefined when calling replacePushNotification().'
);
}

if (requestParameters['pushNotificationReplaceRequest'] == null) {
throw new runtime.RequiredError(
'pushNotificationReplaceRequest',
'Required parameter "pushNotificationReplaceRequest" was null or undefined when calling replacePushNotification().'
);
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';

if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("apiKeyAuth", []);

if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = await this.request({
path: `/push-notification/{notification_id}`.replace(`{${"notification_id"}}`, encodeURIComponent(String(requestParameters['notificationId']))),
method: 'PUT',
headers: headerParameters,
query: queryParameters,
body: requestParameters['pushNotificationReplaceRequest'],
}, initOverrides);

return new runtime.JSONApiResponse(response);
}

/**
* Replaces a Push Notification you already sent, using the `notification_id` from the send response. The replacement takes the original\'s place on the Lock Screen and in Notification Center instead of appearing as a second notification. It is delivered silently, with no sound or screen wake, to the same recipients as the original. Notification history is updated in place.
* Replace a push notification
*/
async replacePushNotification(requestParameters: ReplacePushNotificationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<PushNotificationReplaceResponse> {
const response = await this.replacePushNotificationRaw(requestParameters, initOverrides);
return await response.value();
}

/**
* Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`. Optional `icon` shows a custom image, such as a logo or avatar, next to a smaller app icon. Optional `interruption_level` sets how urgently iOS presents the notification. Optional tags to organize and filter notification history.
* Send a push notification
*/
async sendPushNotificationRaw(requestParameters: SendPushNotificationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<PushNotificationResponse>> {
Expand Down Expand Up @@ -71,7 +132,7 @@ export class PushNotificationsApi extends runtime.BaseAPI {
}

/**
* Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`. Optional `icon` shows a custom image, such as a service logo or avatar, next to a smaller app icon. Optional `interruption_level` sets how urgently iOS presents the notification. Optional tags to organize and filter notification history.
* Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`. Optional `icon` shows a custom image, such as a logo or avatar, next to a smaller app icon. Optional `interruption_level` sets how urgently iOS presents the notification. Optional tags to organize and filter notification history.
* Send a push notification
*/
async sendPushNotification(requestParameters: SendPushNotificationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<PushNotificationResponse> {
Expand Down
Loading
Loading