Links

Devices API

Overview of mobile devices API methods
post
https://api.codemash.io
/:version/notifications/push/devices
Register Device
.NET
Node
PHP
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'
]
}
}
post
https://api.codemash.io
/:version/notifications/push/token/expo
Register Expo Token
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.RegisterExpoTokenAsync(
new RegisterDeviceExpoTokenRequest
{
UserId = Guid.parse("{USER_ID}"),
Token = "ExponentPushToken[**********************]",
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 registerExpoToken()
{
$responseData = $this->codemashPushNotification->registerExpoToken([
'userId' => '{USER_ID}',
'timeZone' => 'Etc/UTC',
'meta' => [
'Brand' => 'Apple'
],
'token' => 'ExponentPushToken[**********************]',
]);
}
}
get
https://api.codemash.io
/:version/notifications/push/devices/:id
Get Device
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.GetDeviceAsync(
new GetDeviceRequest
{
Id = "{DEVICE_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 getDevice()
{
$responseData = $this->codemashPushNotification->getDevice([
'id' => '{DEVICE_ID}',
]);
}
}
get
https://api.codemash.io
/:version/notifications/push/devices
Get Devices
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.GetDevicesAsync(
new GetDevicesRequest()
);
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 getDevices()
{
$responseData = $this->codemashPushNotification->getDevices();
}
}
delete
https://api.codemash.io
/:version/notifications/push/devices/:id
Delete Device
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.DeleteDeviceAsync(
new DeleteDeviceRequest
{
Id = "{DEVICE_ID}"
}
);
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 deleteDevice()
{
$responseData = $this->codemashPushNotification->deleteDevice([
'id' => '{DEVICE_ID}',
]);
}
}
delete
https://api.codemash.io
/:version/notifications/push/devices/:id/token
Delete Device Token
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.DeleteTokenAsync(
new DeleteDeviceTokenRequest
{
Id = "{DEVICE_ID}"
}
);
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 deleteDeviceToken()
{
$responseData = $this->codemashPushNotification->deleteDeviceToken([
'id' => '{DEVICE_ID}',
]);
}
}
patch
https://api.codemash.io
/:version/notifications/push/devices/:id/metadata
Update Device Meta
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.UpdateDeviceMetaAsync(
new UpdateDeviceMetaRequest
{
Id = "{DEVICE_ID}",
Meta = new Dictionary<string, string>
{
{ "Os", "iOs" }
}
}
);
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 updateDeviceMeta()
{
$responseData = $this->codemashPushNotification->updateDeviceMeta([
'id' => '{DEVICE_ID}',
'meta' => ['Brand' => 'Apple'],
]);
}
}
patch
https://api.codemash.io
/:version/notifications/push/devices/:id/timezone
Update Device Timezone
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.UpdateDeviceTimeZoneAsync(
new UpdateDeviceTimeZoneRequest
{
Id = "{DEVICE_ID}",
TimeZone = "Etc/UTC",
}
);
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 updateDeviceTimezone()
{
$responseData = $this->codemashPushNotification->updateDeviceTimezone([
'id' => '{DEVICE_ID}',
'timezone' => 'ETC/UTC',
]);
}
}
patch
https://api.codemash.io
/:version/notifications/push/devices/:id/timezone
Update Device User
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
var response = await pushService.UpdateDeviceUserRequest(
new UpdateDeviceUserRequest
{
Id = "{DEVICE_ID}",
UserId = Guid.Parse("{USER_ID}"),
}
);
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 updateDeviceUser()
{
$responseData = $this->codemashPushNotification->updateDeviceUser([
'id' => '{DEVICE_ID}',
'userId' => '{USER_ID}',
]);
}
}
Last modified 2yr ago