Skip to content

tinode/pushtype

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

pushtype β€” Common push types and error definitions πŸ”§

TL;DR

This package contains shared type definitions and constants used by both the Tinode Push Gateway (TNPG) and the FCM push implementation. It centralizes payload shapes (notifications/data), configuration helpers, and canonical error codes returned by push adapters.

Contents

  • Payload β€” notification payload fields used for Android, iOS (APNS), and web pushes.
  • Config β€” per-notification-type defaults and helpers (GetStringField, GetIntField).
  • TNPGResponse β€” standardized per-message response returned by the push gateway adapters (fields: MessageID, Code, ErrorCode, ErrorMessage, Index).
  • Action constants β€” ActMsg, ActSub, ActRead (message, subscription, read).
  • Platform enums/constants β€” Android visibility, notification priorities, APNS headers and push types.
  • FCM error constants β€” canonical string error codes (e.g., ErrorUnregistered, ErrorInvalidArgument, ErrorQuotaExceeded) used by adapters to normalize Google API errors.

Usage

Import the package and reference the shared types:

import "github.com/tinode/pushtype"

var p pushtype.Payload

// or a TNPG response
var resp pushtype.TNPGResponse

Adapters should use the constants here to map provider errors to stable values consumed by the rest of the system.

Notes & Best Practices πŸ’‘

  • Keep mapping logic in adapters (e.g., decoding Google API errors) and map to the constants in this package so the rest of the system has a stable error vocabulary.
  • Use Config helpers to centralize defaults and avoid duplicated field lookups across adapters.
  • When adding new error codes, include a short comment describing when it is used and how to recover (if applicable).

If you want, I can add a short example showing how to map a Google API error into a TNPGResponse using the constants in this package. βœ…

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages