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 `interruptionLevel` to deliver it as `passive`, `active`, or `time-sensitive`.
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,25 @@ $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.

```php
$sent = $activitysmith->notifications->send(
title: '🚨 checkout-api is down',
message: '500 errors on 62% of requests.',
);

$activitysmith->notifications->replace(
$sent->getNotificationId(),
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
581 changes: 581 additions & 0 deletions generated/Api/PushNotificationsApi.php

Large diffs are not rendered by default.

114 changes: 108 additions & 6 deletions generated/Model/AppIconBadgeCountUpdateResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ class AppIconBadgeCountUpdateResponse implements ModelInterface, ArrayAccess, \J
'devicesNotified' => 'int',
'usersNotified' => 'int',
'effectiveChannelSlugs' => 'string[]',
'timestamp' => '\DateTime'
'timestamp' => '\DateTime',
'devicesTargeted' => 'int',
'devicesDeactivated' => 'int',
'devicesUnregistered' => 'int'
];

/**
Expand All @@ -82,7 +85,10 @@ class AppIconBadgeCountUpdateResponse implements ModelInterface, ArrayAccess, \J
'devicesNotified' => null,
'usersNotified' => null,
'effectiveChannelSlugs' => null,
'timestamp' => 'date-time'
'timestamp' => 'date-time',
'devicesTargeted' => null,
'devicesDeactivated' => null,
'devicesUnregistered' => null
];

/**
Expand All @@ -98,7 +104,10 @@ class AppIconBadgeCountUpdateResponse implements ModelInterface, ArrayAccess, \J
'devicesNotified' => false,
'usersNotified' => false,
'effectiveChannelSlugs' => false,
'timestamp' => false
'timestamp' => false,
'devicesTargeted' => false,
'devicesDeactivated' => false,
'devicesUnregistered' => false
];

/**
Expand Down Expand Up @@ -194,7 +203,10 @@ public function isNullableSetToNull(string $property): bool
'devicesNotified' => 'devices_notified',
'usersNotified' => 'users_notified',
'effectiveChannelSlugs' => 'effective_channel_slugs',
'timestamp' => 'timestamp'
'timestamp' => 'timestamp',
'devicesTargeted' => 'devices_targeted',
'devicesDeactivated' => 'devices_deactivated',
'devicesUnregistered' => 'devices_unregistered'
];

/**
Expand All @@ -210,7 +222,10 @@ public function isNullableSetToNull(string $property): bool
'devicesNotified' => 'setDevicesNotified',
'usersNotified' => 'setUsersNotified',
'effectiveChannelSlugs' => 'setEffectiveChannelSlugs',
'timestamp' => 'setTimestamp'
'timestamp' => 'setTimestamp',
'devicesTargeted' => 'setDevicesTargeted',
'devicesDeactivated' => 'setDevicesDeactivated',
'devicesUnregistered' => 'setDevicesUnregistered'
];

/**
Expand All @@ -226,7 +241,10 @@ public function isNullableSetToNull(string $property): bool
'devicesNotified' => 'getDevicesNotified',
'usersNotified' => 'getUsersNotified',
'effectiveChannelSlugs' => 'getEffectiveChannelSlugs',
'timestamp' => 'getTimestamp'
'timestamp' => 'getTimestamp',
'devicesTargeted' => 'getDevicesTargeted',
'devicesDeactivated' => 'getDevicesDeactivated',
'devicesUnregistered' => 'getDevicesUnregistered'
];

/**
Expand Down Expand Up @@ -294,6 +312,9 @@ public function __construct(array $data = null)
$this->setIfExists('usersNotified', $data ?? [], null);
$this->setIfExists('effectiveChannelSlugs', $data ?? [], null);
$this->setIfExists('timestamp', $data ?? [], null);
$this->setIfExists('devicesTargeted', $data ?? [], null);
$this->setIfExists('devicesDeactivated', $data ?? [], null);
$this->setIfExists('devicesUnregistered', $data ?? [], null);
}

/**
Expand Down Expand Up @@ -591,6 +612,87 @@ public function setTimestamp($timestamp)

return $this;
}

/**
* Gets devicesTargeted
*
* @return int|null
*/
public function getDevicesTargeted()
{
return $this->container['devicesTargeted'];
}

/**
* Sets devicesTargeted
*
* @param int|null $devicesTargeted Number of device tokens targeted.
*
* @return self
*/
public function setDevicesTargeted($devicesTargeted)
{
if (is_null($devicesTargeted)) {
throw new \InvalidArgumentException('non-nullable devicesTargeted cannot be null');
}
$this->container['devicesTargeted'] = $devicesTargeted;

return $this;
}

/**
* Gets devicesDeactivated
*
* @return int|null
*/
public function getDevicesDeactivated()
{
return $this->container['devicesDeactivated'];
}

/**
* Sets devicesDeactivated
*
* @param int|null $devicesDeactivated Number of device tokens deactivated because APNs reported them unregistered.
*
* @return self
*/
public function setDevicesDeactivated($devicesDeactivated)
{
if (is_null($devicesDeactivated)) {
throw new \InvalidArgumentException('non-nullable devicesDeactivated cannot be null');
}
$this->container['devicesDeactivated'] = $devicesDeactivated;

return $this;
}

/**
* Gets devicesUnregistered
*
* @return int|null
*/
public function getDevicesUnregistered()
{
return $this->container['devicesUnregistered'];
}

/**
* Sets devicesUnregistered
*
* @param int|null $devicesUnregistered Number of targeted device tokens APNs reported as unregistered.
*
* @return self
*/
public function setDevicesUnregistered($devicesUnregistered)
{
if (is_null($devicesUnregistered)) {
throw new \InvalidArgumentException('non-nullable devicesUnregistered cannot be null');
}
$this->container['devicesUnregistered'] = $devicesUnregistered;

return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
Expand Down
Loading
Loading