CodeMash
  • 🚀Backend as a service
  • 🦄Roadmap
  • 🍕Release Notes
  • Installation
    • Managed Service
    • 🏗️AWS-CDK
    • 🏗️Azure
    • 🏗️Docker
    • 🏗️GC
    • 🏗️Terraform
  • dashboard
    • CodeMash Cloud
    • Project
    • Membership
      • Users
      • Roles
      • Policies
      • Triggers
      • Integrations
        • Apple
        • Azure
        • Facebook
        • Google
        • Twitter
      • Settings
    • Database
      • Collections
        • Schema
          • From Template
          • Structure
        • Tabs
        • Triggers
        • Indexes
        • Shared Forms
      • Taxonomies
        • Terms
        • Schema
        • Settings
      • Aggregation
      • Imports
      • Exports
      • Backups
    • Files
      • Integrations
        • CodeMash
        • S3 Bucket
    • Notifications
      • Push
        • Push Templates
        • Push Templates API
        • Push Notifications
        • Push Notifications API
        • Devices
        • Devices API
        • Integrations
          • Firebase
          • One Signal
          • Expo
      • Email
        • Email Templates
        • Emails
        • Integrations
          • AWS SES
          • Twilio Sendgrid
          • Mailgun
      • 🏗️Server events
      • 🏗️Sms
    • Payments
      • Integrations
        • Apple Pay
        • Google Pay
        • Stripe
        • Kevin.
        • Paysera
        • Decta
    • Scheduler
    • Logs & Monitoring
    • Code
      • Functions
        • Function Inputs
        • Function Templates
          • Node.js
          • Python
          • Ruby
          • Java
          • Go
          • .NET Core
      • CodeMash Functions
        • Google Functions
          • Google Calendar
          • Google Gmail
        • Microsoft Functions
          • Microsoft 365 Users
          • Microsoft 365 Calendar
        • Collection Find
        • Collection Update
        • Users Find
        • Image Resize
        • Html To Pdf
        • Word Document
        • Barcode
        • QR Code
        • Send Email
        • Send Notification
        • Email Reminder
        • Notification Reminder
      • Integrations
        • AWS Lambda
        • Google Cloud Functions
        • Azure Functions
  • Other Topics
    • Apple
      • Developer Portal
      • Bundle Identifier
      • Team ID
      • Service ID
      • Key ID
    • Triggers
    • Tokens Binding
      • Project Tokens
      • Initiator Tokens
      • Receiver Tokens
      • Request Tokens
      • Operation based tokens
      • Template Functions
    • Search parameters
      • Paging
      • Filter
      • Sort
      • Projection
    • data-models
    • Errors
  • SDK
    • Node.js
    • TypeScript
    • .NET
    • 🏗️Go Lang
    • 🏗️Flutter
    • 🏗️Swift
    • 🏗️Kotlin
  • CLI
    • 🏗️CodeMash CLI
  • API
    • Get Started
    • Prerequisites
    • How to test?
    • Cors
    • Project
    • Membership
      • Authentication
      • Users
    • Database
      • Collections
        • Aggregate
        • Change Responsibility
        • Count
        • Delete
        • Delete Many
        • Distinct
        • Find
        • Find One
        • Insert
        • Insert Many
        • References
        • Replace
        • Update
        • Update Many
      • Taxonomies
        • Find
    • Files
    • Code
    • Notifications
      • Push
      • Emails
      • Server Events
      • 🏗️Sms
    • Payments
    • Scheduler
    • Logs & Monitoring
Powered by GitBook
On this page
  • Register Device
  • Register Expo Token
  • Get Device
  • Get Devices
  • Delete Device
  • Delete Device Token
  • Update Device Meta
  • Update Device Timezone
  • Update Device User

Was this helpful?

Edit on GitHub
  1. dashboard
  2. Notifications
  3. Push

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

Name
Type
Description

version

string

The version of the API endpoint. Current latest v1.

Headers

Name
Type
Description

Authorization

string

Your project's secret key.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

Request Body

Name
Type
Description

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

Name
Type
Description

version

string

The version of the API endpoint. Current latest v1.

Headers

Name
Type
Description

Authorization

string

Your project's secret key.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

Request Body

Name
Type
Description

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.

{
    Result: ""
}
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 Device

GET https://api.codemash.io/:version/notifications/push/devices/:id

Gets a device.

Path Parameters

Name
Type
Description

version

string

The version of the API endpoint. Current latest v1.

id

string

The ID of a device to get.

Headers

Name
Type
Description

Authorization

string

Your project's secret key.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

{
    Result: ""
}
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 Devices

GET https://api.codemash.io/:version/notifications/push/devices

Gets many devices.

Path Parameters

Name
Type
Description

version

string

The version of the API endpoint. Current latest v1.

Headers

Name
Type
Description

Authorization

string

Your project's secret key.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

{
    Result: ""
}
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 Device

DELETE https://api.codemash.io/:version/notifications/push/devices/:id

Deletes a particular device.

Path Parameters

Name
Type
Description

version

string

The version of the API endpoint. Current latest v1.

id

string

The ID of a device to delete.

Headers

Name
Type
Description

Authorization

string

Your project's secret key.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

{
    Result: ""
}
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 Device Token

DELETE https://api.codemash.io/:version/notifications/push/devices/:id/token

Deletes a token of a particular device.

Path Parameters

Name
Type
Description

version

string

The version of the API endpoint. Current latest v1.

id

string

The ID of a device.

Headers

Name
Type
Description

Authorization

string

Your project's secret key.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

{
    Result: ""
}
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}',
        ]);
    }
    
}

Update Device Meta

PATCH https://api.codemash.io/:version/notifications/push/devices/:id/metadata

Updates a meta-information of a particular device.

Path Parameters

Name
Type
Description

version

string

The version of the API endpoint. Current latest v1.

id

string

The ID of a device to update.

Headers

Name
Type
Description

Authorization

string

Your project's secret key.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

Request Body

Name
Type
Description

meta

string

Key-value pair (string: string) object of custom data.

{
    Result: ""
}
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'],
        ]);
    }
    
}

Update Device Timezone

PATCH https://api.codemash.io/:version/notifications/push/devices/:id/timezone

Updates a timezone of a particular device.

Path Parameters

Name
Type
Description

version

string

The version of the API endpoint. Current latest v1.

id

string

The ID of a device to update.

Headers

Name
Type
Description

Authorization

string

Your project's secret key.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

Request Body

Name
Type
Description

timezone

string

The timezone of a device in a tz database format.

{
    Result: ""
}
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',
        ]);
    }
    
}

Update Device User

PATCH https://api.codemash.io/:version/notifications/push/devices/:id/timezone

Updates a user of a particular device.

Path Parameters

Name
Type
Description

version

string

The version of the API endpoint. Current latest v1.

id

string

The ID of a device to update.

Headers

Name
Type
Description

Authorization

string

Your project's secret key.

x-cm-projectid

string

Your project's ID. Can be passed as a query parameter.

Request Body

Name
Type
Description

userId

string

The ID of a new user.

{
    Result: ""
}
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}',
        ]);
    }
    
}
PreviousDevicesNextIntegrations

Last updated 4 years ago

Was this helpful?