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
  • Using SDK
  • Example
  • Working with Push Service

Was this helpful?

Edit on GitHub
  1. dashboard
  2. Notifications

Push

Send personal or bulk push notifications to your clients. Schedule them, plan to send by client time zone, and have different languages over each message you deliver.

CodeMash Push Notifications service allows you to push mobile notifications to your users. All notifications queuing and management is accessible through the dashboard. Using API methods you can register devices, push messages, and more.

To start using the push notifications service and it's API methods, you firstly need to enable push notifications service in your CodeMash dashboard.

Using SDK

If you decide to use one of our provided SDK, the following code shows how to initialize the notifications service.

var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
var apiKey = "{YOUR_SECRET_KEY}";

var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);
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);
    }
}

Example

The following are examples of push notifications SDK using different languages and frameworks.

using System;
using CodeMash.Client;
using CodeMash.Notifications.Push.Services;
using Isidos.CodeMash.ServiceContracts;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            // 1. Get your Project ID and Secret Key
            var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
            var apiKey = "{YOUR_SECRET_KEY}";

            // 2. Create a general client for API calls
            var client = new CodeMashClient(apiKey, projectId);
            
            // 3. Create a service object
            var pushService = new CodeMashPushService(client);

            // 4. Call an API method
            var response = pushService.SendPushNotification(
                new SendPushNotificationRequest
                {
                    TemplateId = Guid.Parse("{TEMPLATE_ID}"),
                    Users = new List<Guid> { Guid.Parse("{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}',
            ],
        ]);
    }
    
}

Working with Push Service

The following links explore the usage of push notifications service:

PreviousNotificationsNextPush Templates

Last updated 2 years ago

Was this helpful?

Push Notifications API