Devices API
Overview of mobile devices API methods
Register Device
POST https://api.codemash.io/:version/notifications/push/devices
Registers a device without a token. Devices without a token won't receive push notifications.
Path Parameters
version
string
The version of the API endpoint. Current latest v1.
Headers
Authorization
string
Your project's secret key.
x-cm-projectid
string
Your project's ID. Can be passed as a query parameter.
Request Body
userId
string
The ID of a user.
timeZone
string
The timezone of a device in a tz database format.
meta
object
Key-value pair (string: string) object for custom data.
{
Result: ""
}var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.RegisterDeviceAsync(
new RegisterDeviceRequest
{
UserId = Guid.parse("{USER_ID}"),
TimeZone = "Etc/UTC",
Meta = new Dictionary<string, string>
{
{ "Os", "Android" }
}
}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 registerDevice()
{
$responseData = $this->codemashPushNotification->registerDevice([
'userId' => '{USER_ID}',
'timeZone' => 'Etc/UTC',
'meta' => [
'Brand' => 'Apple'
]
}
}Register Expo Token
POST https://api.codemash.io/:version/notifications/push/token/expo
Registers a device with an Expo token and creates a device if not yet created.
Path Parameters
version
string
The version of the API endpoint. Current latest v1.
Headers
Authorization
string
Your project's secret key.
x-cm-projectid
string
Your project's ID. Can be passed as a query parameter.
Request Body
token
string
Token of a device provided by the Expo.
deviceId
string
The ID of a device. If not provided, a new device will be added.
userId
string
The ID of a user.
timeZone
string
The timezone of a device in a tz database format.
meta
object
Key-value pair (string: string) object for custom data.
Get Device
GET https://api.codemash.io/:version/notifications/push/devices/:id
Gets a device.
Path Parameters
version
string
The version of the API endpoint. Current latest v1.
id
string
The ID of a device to get.
Headers
Authorization
string
Your project's secret key.
x-cm-projectid
string
Your project's ID. Can be passed as a query parameter.
Get Devices
GET https://api.codemash.io/:version/notifications/push/devices
Gets many devices.
Path Parameters
version
string
The version of the API endpoint. Current latest v1.
Headers
Authorization
string
Your project's secret key.
x-cm-projectid
string
Your project's ID. Can be passed as a query parameter.
Delete Device
DELETE https://api.codemash.io/:version/notifications/push/devices/:id
Deletes a particular device.
Path Parameters
version
string
The version of the API endpoint. Current latest v1.
id
string
The ID of a device to delete.
Headers
Authorization
string
Your project's secret key.
x-cm-projectid
string
Your project's ID. Can be passed as a query parameter.
Delete Device Token
DELETE https://api.codemash.io/:version/notifications/push/devices/:id/token
Deletes a token of a particular device.
Path Parameters
version
string
The version of the API endpoint. Current latest v1.
id
string
The ID of a device.
Headers
Authorization
string
Your project's secret key.
x-cm-projectid
string
Your project's ID. Can be passed as a query parameter.
Update Device Meta
PATCH https://api.codemash.io/:version/notifications/push/devices/:id/metadata
Updates a meta-information of a particular device.
Path Parameters
version
string
The version of the API endpoint. Current latest v1.
id
string
The ID of a device to update.
Headers
Authorization
string
Your project's secret key.
x-cm-projectid
string
Your project's ID. Can be passed as a query parameter.
Request Body
meta
string
Key-value pair (string: string) object of custom data.
Update Device Timezone
PATCH https://api.codemash.io/:version/notifications/push/devices/:id/timezone
Updates a timezone of a particular device.
Path Parameters
version
string
The version of the API endpoint. Current latest v1.
id
string
The ID of a device to update.
Headers
Authorization
string
Your project's secret key.
x-cm-projectid
string
Your project's ID. Can be passed as a query parameter.
Request Body
timezone
string
The timezone of a device in a tz database format.
Update Device User
PATCH https://api.codemash.io/:version/notifications/push/devices/:id/timezone
Updates a user of a particular device.
Path Parameters
version
string
The version of the API endpoint. Current latest v1.
id
string
The ID of a device to update.
Headers
Authorization
string
Your project's secret key.
x-cm-projectid
string
Your project's ID. Can be passed as a query parameter.
Request Body
userId
string
The ID of a new user.
Last updated
Was this helpful?