Links

Push Notifications API

Overview of push notifications API methods
post
https://api.codemash.io
/:version/notifications/push
Send Push Notification
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.SendPushNotificationAsync(
new SendPushNotificationRequest
{
TemplateId = Guid.Parse("{TEMPLATE_ID}"),
Users = new List<string> { "{USER_ID}" }
}
);
use Codemash\CodemashClient;
use Codemash\CodemashPushNotification;
class CodemashService
{
protected CodemashPushNotification $codemashPushNotification;
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
$client = new CodemashClient($secretKey, $projectId);
$codemashPushNotification = new CodemashPushNotification($client);
}
public function sendPushNotification()
{
$responseData = $this->codemashPushNotification->sendNotification([
'templateId' => '{TEMPLATE_ID}',
'users' => [
'{USER_ID}',
'{USER_ID}',
'{USER_ID}',
],
]);
}
}
get
https://api.codemash.io
/:version/notifications/push/:id
Get Notification
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.GetNotificationAsync(
new GetNotificationRequest
{
Id = "{NOTIFICATION_ID}"
}
);
use Codemash\CodemashClient;
use Codemash\CodemashPushNotification;
class CodemashService
{
protected CodemashPushNotification $codemashPushNotification;
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
$client = new CodemashClient($secretKey, $projectId);
$codemashPushNotification = new CodemashPushNotification($client);
}
public function getNotification()
{
$responseData = $this->codemashPushNotification->getNotification([
'id' => '{NOTIFICATION_ID}',
]);
}
}
get
https://api.codemash.io
/:version/notifications/push
Get Notifications
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.GetNotificationsAsync(
new GetNotificationsRequest
{
UserId = "{USER_ID}"
}
);
use Codemash\CodemashClient;
use Codemash\CodemashPushNotification;
class CodemashService
{
protected CodemashPushNotification $codemashPushNotification;
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
$client = new CodemashClient($secretKey, $projectId);
$codemashPushNotification = new CodemashPushNotification($client);
}
public function getNotifications()
{
$responseData = $this->codemashPushNotification->getNotifications([
'userId' => '{USER_ID}',
]);
}
}
If you do not specify user ID or device ID, the method will return notifications directed to the calling user. To get any user's or device's notifications, the calling user need's to have the appropriate permission for that.
get
https://api.codemash.io
/:version/notifications/push/count
Get Notifications Count
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.GetNotificationsCountAsync(
new GetNotificationsCountRequest
{
UserId = "{USER_ID}"
}
);
use Codemash\CodemashClient;
use Codemash\CodemashPushNotification;
class CodemashService
{
protected CodemashPushNotification $codemashPushNotification;
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
$client = new CodemashClient($secretKey, $projectId);
$codemashPushNotification = new CodemashPushNotification($client);
}
public function getNotificationsCount()
{
$responseData = $this->codemashPushNotification->getNotificationCount([
'userId' => '{USER_ID}',
]);
}
}
If you do not specify user ID or device ID, the method will return notifications directed to the calling user. To get any user's or device's notifications, the calling user need's to have the appropriate permission for that.
patch
https://api.codemash.io
/:version/notifications/push/:notificationId/read
Read Notification
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.ReadNotificationAsync(
new MarkNotificationAsReadRequest
{
NotificationId = "{NOTIFICATION_ID}"
}
);
use Codemash\CodemashClient;
use Codemash\CodemashPushNotification;
class CodemashService
{
protected CodemashPushNotification $codemashPushNotification;
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
$client = new CodemashClient($secretKey, $projectId);
$codemashPushNotification = new CodemashPushNotification($client);
}
public function readNotification()
{
$responseData = $codemashPushNotification->readNotification([
'id' => '{NOTIFICATION_ID}',
]);
}
}
If you do not specify user ID or device ID, the method will assume that notification was directed to a calling user. If you want to set other user's notification as read, you need to have the appropriate permission for that.
delete
https://api.codemash.io
/:version/notifications/push/:id
Delete Notification
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.DeleteNotificationAsync(
new DeleteNotificationRequest
{
Id = "{NOTIFICATION_ID}"
}
);
use Codemash\CodemashClient;
use Codemash\CodemashPushNotification;
class CodemashService
{
protected CodemashPushNotification $codemashPushNotification;
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
$client = new CodemashClient($secretKey, $projectId);
$codemashPushNotification = new CodemashPushNotification($client);
}
public function deleteNotification()
{
$responseData = $codemashPushNotification->deleteNotification([
'id' => '{NOTIFICATION_ID}',
]);
}
}