To be able to send APNS notifications to Apple servers or GCM notifications to Google servers, application certificates (APNS) or an application key (GCM) must be specified in the application settings.
To subscribe to notifications, the client must invoke the account.registerDevice query, passing in token_type and token as parameters that identify the current device. It is useful to repeat this query at least once every 24 hours or when restarting the application. Use account.unregisterDevice to unsubscribe.
The following token_types are supported:
1 - APNS (device token for apple push)2 - FCM (firebase token for google firebase)3 - MPNS (channel URI for microsoft push)4 - Simple push (endpoint for firefox's deprecated simple push API): note that this push type can also be used by an open source push notification spec like UnifiedPush ยป.version=number payload to the specified HTTPS endpoint every time a relevant message is received: upon receiving such a notification, clients should connect to the MTProto API and fetch updates.number won't necessarily be incremental in Telegram's implementation, just treat each distinct request as a signal that a new message is waiting to be fetched via MTProto).5 - Ubuntu phone (token for ubuntu push)6 - Blackberry (token for blackberry push)7 - MTProto separate session8 - WNS (windows push)9 - APNS VoIP (token for apple push VoIP)10 - Web push (web push, see below)11 - MPNS VoIP (token for microsoft push VoIP)12 - Tizen (token for tizen push)13 - Huawei pushFor 10 web push, the token must be a JSON-encoded object with the following keys:
endpoint: Absolute URL exposed by the push service where the application server can send push messageskeys: P-256 elliptic curve Diffie-Hellman parameters in the following object
p256dh: Base64url-encoded P-256 elliptic curve Diffie-Hellman public keyauth: Base64url-encoded authentication secretFor FCM and APNS VoIP, an optional encryption key used to encrypt push notifications can be passed to account.registerDevice (secret). This key (auth_key) is used to encrypt the payloads using MTProto v2.
The FCM payload will be a JSON payload, containing a p field with the base64url-encoded encrypted MTProto payload. After decryption, the result will be a JSON object, prefixed by a 32-bit little-endian integer with the length of the JSON payload. As usual, make sure to follow all security checks as described in the MTProto docs.
As mentioned above, payloads can also be encrypted using P-256 Elliptic Curve Diffie-Hellman when using web push.
An (optionally encrypted) notification is provided as a JSON object in the following format:
{
"data": {
"loc_key": "CHAT_MESSAGE_CONTACT",
"loc_args": ["John Doe", "My magical group", "Contact Exchange"],
"user_id": 14124122,
"custom": {
"chat_id": 241233,
"msg_id": 123
},
"sound": "sound1.mp3",
}
}
Each notification has several parameters that describe it.
/[A-Z_0-9]+/, which summarizes the notification. For example, CHAT_MESSAGE_TEXT.push flag and passing the ID and the peer of this message as soon as it is received by the client (optionally batching requests for the same peer), used for Telegram Gateway verification messages.In principle, data.loc_key, data.custom, and an Internet connection are sufficient to generate a notification. Obviously, if possible, when generating a visual notification you need not use all of the transmitted data and may rely on the information already stored on the client. But if a user or a chat is not cached locally, the values passed in loc_args may also be used. data.user_id is the ID of the account to which the PUSH notification should be delivered, in case of clients with multiple accounts active and running.
The following notifications are handled specially by clients to update local app state or synthesize lightweight local events, instead of displaying an ordinary message notification.
Extra custom arguments
data.custom.dc - number of the data-center
data.custom.addr - server address with port number in the format 111.112.113.114:443
Description
Add the received server address to the list of possible addresses for the specified DC.
If the address of the first DC was passed (dc=1), it is recommended to call help.getConfig immediately to refresh the DC configuration.
Template example
Open this notification to update app settings
Arguments
This notification does not use placeholder arguments.
Extra custom arguments
data.custom.channel_id: For channels and supergroups, Channel/supergroup identifier
data.custom.chat_id: For chats, Chat identifier
data.custom.from_id: For PMs, Author identifier
data.custom.messages: Comma-separated IDs of messages that were deleted
Description
Messages were deleted in the specified dialog: remove local notifications for the listed messages.
data.custom.messages contains a comma-separated list of server-side message IDs.
Extra custom arguments
data.custom.channel_id: For channels and supergroups, Channel/supergroup identifier
data.custom.chat_id: For chats, Chat identifier
data.custom.from_id: For PMs, Author identifier
data.custom.topic_id: Optional forum topic identifier
data.custom.messages: Comma-separated IDs of messages whose reactions were read
Description
Reactions were read on the specified messages: remove local reaction-related notifications for those messages.
Extra custom arguments
data.custom.channel_id: For channels and supergroups, Channel/supergroup identifier
data.custom.chat_id: For chats, Chat identifier
data.custom.from_id: For PMs, Author identifier
data.custom.max_id: Maximum ID of read messages
Description
Message history was read in the specified non-secret dialog: mark incoming history up to data.custom.max_id as read and remove the corresponding notifications.
Extra custom arguments
data.custom.channel_id: For channels and supergroups, Channel/supergroup identifier
data.custom.from_id: For user-sent stories, Author identifier
data.custom.max_id: Maximum ID of read story
Description
Story notifications were read for the specified user or channel: mark stories up to data.custom.max_id as read and remove the corresponding story-related notifications.
Extra custom arguments
data.custom.channel_id: For channels and supergroups, Channel/supergroup identifier
data.custom.from_id: For user-sent stories, Author identifier
data.custom.story_id: Comma-separated list of IDs of deleted stories
Description
A story was deleted: remove local notifications for that story.
Extra custom arguments
data.custom.channel_id: For channels and supergroups, Channel/supergroup identifier
data.custom.from_id: For user-sent stories, Author identifier
data.custom.story_id: ID of the story
Description
A new story without text was posted.
Template example
posted a story
Arguments
This notification does not use placeholder arguments.
Extra custom arguments
data.custom.channel_id: For channels and supergroups, Channel/supergroup identifier
data.custom.from_id: For user-sent stories, Author identifier
data.custom.story_id: ID of the story
Description
A story live stream was started.
Template example
started a live stream!
Arguments
This notification does not use placeholder arguments.
Extra custom arguments
data.custom.channel_id: For channels and supergroups, Channel/supergroup identifier
data.custom.from_id: For user-sent stories, Author identifier
data.custom.story_id: ID of the story
Description
A new story was posted, but the client should not expose the author in the visible notification text.
Template example
A new story was posted
Arguments
This notification does not use placeholder arguments.
Description
Refresh any live locations currently being watched or shared.
This push is a wake-up hint and does not need placeholder arguments or a user-visible notification.
Description
Logout and remove DB for specified session by data.user_id, only apply if coming from an MTProto-encrypted payload
Description
Sent rarely for muted chats, roughly every 10th muted chat message or about once every 15 seconds in PMs, to refresh badge state or trigger fetching updates from the server.
This push is not meant to be shown to the user as a visible notification.
Extra custom arguments
data.custom.announcement: Announcement ID (integer)
Extra top-level arguments
data.message: Non-empty announcement text
Description
Roughly equivalent to a message received from the service notifications (updateServiceNotification with type="announcement"), but is delivered via push notifications, without contacting the API.
The push text is taken from data.message.
Clients may deduplicate repeated announcements using the announcement ID in data.custom.announcement: for example, by storing received IDs for 7 days, persisting the cache across restarts.
Template example
New login from unrecognized device {1}, location: {2}
Arguments
Template example
New login from unrecognized device {1}
Arguments
Template example
{1} posted an album
Arguments
Template example
{1} posted a voice message
Arguments
Template example
{1} posted a contact {2}
Arguments
Template example
{1} posted a file
Arguments
Template example
{1} posted {2} files
Arguments
Template example
{1} posted {2} forwarded messages
Arguments
Template example
{1} invited you to play {2}
Arguments
Template example
{1} scored {3} in game {2}
Arguments
Template example
{1} posted a location
Arguments
Template example
{1} posted a live location
Arguments
Template example
{1} posted a GIF
Arguments
Template example
{1} posted a giveaway of {2}x {3}m Premium subscriptions
Arguments
Template example
{1} posted a giveaway of {3} stars {2}
Arguments
Template example
{1} posted a message
Arguments
Template example
{1} posted a paid post for {2} star
Arguments
Template example
{1} posted a photo
Arguments
Template example
{1} posted {2} photos
Arguments
Template example
{1} posted {2} music files
Arguments
Template example
{1} posted a poll {2}
Arguments
Template example
{1} posted a quiz {2}
Arguments
Template example
{1} posted a video message
Arguments
Template example
{1} posted a {2} sticker
Arguments
Template example
{1} shared a story
Arguments
Template example
{1}: {2}
Arguments
Template example
{1} posted a checklist {2}
Arguments
Template example
{1} added {2} tasks
Arguments
Template example
{1} toggled {2} tasks
Arguments
Template example
{1} posted a video
Arguments
Template example
{1} posted {2} videos
Arguments
Template example
{1} invited {3} to the group {2}
Arguments
Template example
{1} invited you to the group {2}
Arguments
Template example
{1} invited you to the group {2}
Arguments
Template example
{1} removed {3} from the group {2}
Arguments
Template example
{1} removed you from the group {2}
Arguments
Template example
{1} joined the group {2}
Arguments
Template example
{1} left the group {2}
Arguments
Template example
{1} sent an album to the group {2}
Arguments
Template example
{1} sent a voice message to the group {2}
Arguments
Template example
{1} shared a contact {3} in the group {2}
Arguments
Template example
{1} sent a file to the group {2}
Arguments
Template example
{1} sent {3} files to the group {2}
Arguments
Template example
{1} forwarded {3} messages to the group {2}
Arguments
Template example
{1} invited the group {2} to play {3}
Arguments
Template example
{1} scored {4} in game {3} in the group {2}
Arguments
Template example
{1} sent a location to the group {2}
Arguments
Template example
{1} shared a live location with the group {2}
Arguments
Template example
{1} sent a GIF to the group {2}
Arguments
Template example
{1} sent a giveaway of {3}x {4}m Premium subscriptions to the group {2}
Arguments
Template example
{1} sent a giveaway of {4} stars {3} to the group {2}
Arguments
Template example
{1} sent an invoice to the group {2} for {3}
Arguments
Template example
{1} sent a message to the group {2}
Arguments
Template example
{1} posted a paid post in {2} group for {3} star
Arguments
Template example
{1} sent a photo to the group {2}
Arguments
Template example
{1} sent {3} photos to the group {2}
Arguments
Template example
{1} sent {3} music files to the group {2}
Arguments
Template example
{1} sent a poll {3} to the group {2}
Arguments
Template example
{1} sent a quiz {3} to the group {2}
Arguments
Template example
{1} sent a video message to the group {2}
Arguments
Template example
{1} sent a {3} sticker to the group {2}
Arguments
Template example
{1} shared a story to the group
Arguments
Template example
{1} @ {2}: {3}
Arguments
Template example
{1} sent a checklist {3} to the group {2}
Arguments
Template example
{1} added {3} tasks in the group {2}
Arguments
Template example
{1} toggled {3} tasks in the group {2}
Arguments
Template example
{1} sent a video to the group {2}
Arguments
Template example
{1} sent {3} videos to the group {2}
Arguments
Template example
{1} changed the group photo for {2}
Arguments
Template example
{1}: {3} to your voice message in {2}
Arguments
Template example
{1}: {3} to your contact {4} in {2}
Arguments
Template example
{1}: {3} to your file in {2}
Arguments
Template example
{1}: {3} to your game in {2}
Arguments
Template example
{1}: {3} to your map in {2}
Arguments
Template example
{1}: {3} to your live location in {2}
Arguments
Template example
{1}: {3} to your GIF in {2}
Arguments
Template example
{1} reacted {3} in group {2} to your giveaway
Arguments
Template example
{1}: {3} to your invoice in {2}
Arguments
Template example
{1}: {3} to your message in {2}
Arguments
Template example
{1} reacted {3} in group {2} to your paid post for {4} star
Arguments
Template example
{1}: {3} to your photo in {2}
Arguments
Template example
{1}: {3} to your poll {4} in {2}
Arguments
Template example
{1}: {3} to your quiz {4} in {2}
Arguments
Template example
{1}: {3} to your video message in {2}
Arguments
Template example
{1}: {3} to your {4} sticker in {2}
Arguments
Template example
{1}: {3} in {2} to your "{4}"
Arguments
Template example
{1}: {3} to your checklist {4} in {2}
Arguments
Template example
{1}: {3} to your video in {2}
Arguments
Template example
{2}|{1} was accepted into the group
Arguments
Template example
{1} returned to the group {2}
Arguments
Template example
{1} renamed the group {2}
Arguments
Template example
{1} ended a voice chat in the group {2}
Arguments
Template example
{1} invited {3} to a voice chat in the group {2}
Arguments
Template example
{1} invited you to a voice chat in the group {2}
Arguments
Template example
{1} started a voice chat in the group {2}
Arguments
Template example
You missed a call from {1}
Arguments
Template example
{1} joined Telegram!
Arguments
Template example
You have a new message
Arguments
This notification does not use placeholder arguments.
Template example
You have a new message
Arguments
This notification does not use placeholder arguments.
Template example
You have a new message
Arguments
This notification does not use placeholder arguments.
Template example
You have a new message
Arguments
This notification does not use placeholder arguments.
Template example
{1} sent you an album
Arguments
Template example
{1} sent you a voice message
Arguments
Template example
{1} shared a contact {2} with you
Arguments
Template example
{1} sent you a file
Arguments
Template example
{1} sent you {2} files
Arguments
Template example
{1} forwarded you {2} messages
Arguments
Template example
{1} invited you to play {2}
Arguments
Template example
{1} scored {3} in game {2}
Arguments
Template example
{1} sent you a location
Arguments
Template example
{1} sent you a live location
Arguments
Template example
{1} sent you a GIF
Arguments
Template example
{1} sent you a Gift Code for {2} of Telegram Premium
Arguments
Template example
{1} sent you a giveaway of {2}x {3}m Premium subscriptions
Arguments
Template example
{1} sent you a giveaway of {3} stars {2}
Arguments
Template example
{1} sent you an invoice for {2}
Arguments
Template example
{1} sent you a message
Arguments
Template example
{1} sent you a paid post for {2} star
Arguments
Template example
{1} sent you a photo
Arguments
Template example
{1} sent you {2} photos
Arguments
Template example
{1} sent you a self-destructing photo
Arguments
Template example
{1} sent you {2} music files
Arguments
Template example
{1} sent you a poll {2}
Arguments
Template example
{1} sent you a quiz {2}
Arguments
Template example
You were charged {2} by {1}
Arguments
Template example
{1} sent you a video message
Arguments
Template example
{1} set a same wallpaper for this chat
Arguments
Template example
{1} took a screenshot
Arguments
Template example
{1} sent you a Gift worth {2} Stars
Arguments
Template example
{1} unpacked the Gift that you helped upgrade
Arguments
Template example
{1} upgraded your Gift
Arguments
Template example
{1} sent you a {2} sticker
Arguments
Template example
{1} shared a story with you
Arguments
Template example
{1} mentioned you in a story
Arguments
Template example
{1} suggested you your birthday
Arguments
Template example
{1}: {2}
Arguments
Template example
{1} sent you a checklist {2}
Arguments
Template example
{1} transferred you a Gift!
Arguments
Template example
{1} sent you a video
Arguments
Template example
{1} sent you {2} videos
Arguments
Template example
{1} sent you a self-destructing video
Arguments
Template example
{1} set a new wallpaper for this chat
Arguments
Template example
Login request for {1} from {2}
Arguments
data_url field of the custom argumentsTemplate example
You missed a call from {1}
Arguments
Template example
{1} is calling you!
Arguments
Template example 1
{1} pinned a voice message
Arguments
Template example 2
{1} pinned a voice message in the group {2}
Arguments
Template example 1
{1} pinned a contact {2}
Arguments
Template example 2
{1} pinned a contact {3} in the group {2}
Arguments
Template example 1
{1} pinned a file
Arguments
Template example 2
{1} pinned a file in the group {2}
Arguments
Template example 1
{1} pinned a game
Arguments
Template example 2
{1} pinned a game in the group {2}
Arguments
Template example 1
{1} pinned a game score
Arguments
Template example 2
{1} pinned a game score in the group {2}
Arguments
Template example 1
{1} pinned a map
Arguments
Template example 2
{1} pinned a map in the group {2}
Arguments
Template example 1
{1} pinned a live location
Arguments
Template example 2
{1} pinned a live location in the group {2}
Arguments
Template example 1
{1} pinned a GIF
Arguments
Template example 2
{1} pinned a GIF in the group {2}
Arguments
Template example 1
{1} pinned a giveaway
Arguments
Template example 2
{1} pinned a giveaway in the group {2}
Arguments
Template example 1
{1} pinned an invoice
Arguments
Template example 2
{1} pinned an invoice in the group {2}
Arguments
Template example 1
{1} pinned a message
Arguments
Template example 2
{1} pinned a message in the group {2}
Arguments
Template example 1
{1} pinned a paid post for {2} star
Arguments
Template example 2
{1} pinned a paid post for {3} star in the group {2}
Arguments
Template example 1
{1} pinned a photo
Arguments
Template example 2
{1} pinned a photo in the group {2}
Arguments
Template example 1
{1} pinned a poll {2}
Arguments
Template example 2
{1} pinned a poll {3} in the group {2}
Arguments
Template example 1
{1} pinned a quiz {2}
Arguments
Template example 2
{1} pinned a quiz {3} in the group {2}
Arguments
Template example 1
{1} pinned a video message
Arguments
Template example 2
{1} pinned a video message in the group {2}
Arguments
Template example 1
{1} pinned a {2} sticker
Arguments
Template example 2
{1} pinned a {3} sticker in the group {2}
Arguments
Template example 1
{1} pinned "{2}"
Arguments
Template example 2
{1} pinned "{3}" in the group {2}
Arguments
Template example 1
{1} pinned a checklist {2}
Arguments
Template example 2
{1} pinned a checklist {3} in the group {2}
Arguments
Template example 1
{1} pinned a video
Arguments
Template example 2
{1} pinned a video in the group {2}
Arguments
Template example
{1}: {2} to your voice message
Arguments
Template example
{1}: {2} to your contact {3}
Arguments
Template example
{1}: {2} to your file
Arguments
Template example
{1}: {2} to your game
Arguments
Template example
{1}: {2} to your map
Arguments
Template example
{1}: {2} to your live location
Arguments
Template example
{1}: {2} to your GIF
Arguments
Template example
{1} reacted {2} to your giveaway
Arguments
Template example
New reaction to your message
Arguments
This notification does not use placeholder arguments.
Template example
{1}: {2} to your invoice
Arguments
Template example
{1}: {2} to your message
Arguments
Template example
{1}: {2} to your photo
Arguments
Template example
{1}: {2} to your poll {3}
Arguments
Template example
{1}: {2} to your quiz {3}
Arguments
Template example
{1}: {2} to your video message
Arguments
Template example
{1}: {2} to your {3} sticker
Arguments
Template example
{1}: {2} to your story
Arguments
Template example
New reaction to your story
Arguments
This notification does not use placeholder arguments.
Template example
{1}: {2} to your "{3}"
Arguments
Template example
{1}: {2} to your checklist {3}
Arguments
Template example
{1}: {2} to your video
Arguments