Skip to content

Firebase Cloud Messaging - deliver and receive messages and notifications on iOS

License

Notifications You must be signed in to change notification settings

geek1706/fcm-guides

 
 

Repository files navigation

Firebase Cloud Messaging on iOS

Deliver and receive messages and notifications on iOS.

Introduction

Using FCM, you can notify an iOS client app that new email or other data is available to sync. You can send notification messages to drive user re-engagement and retention.

About FCM Messages

Firebase Cloud Messaging (FCM) offers a broad range of messaging options and capabilities

Key capabilities

Capability Explains
Send notification messages or data messages Send notification messages that are displayed to your user. Or send data messages and determine completely what happens in your application code. See Message types.
Versatile message targeting Distribute messages to your client app in any of 3 ways—to single devices, to groups of devices, or to devices subscribed to topics.
Send messages from client apps Send acknowledgments, chats, and other messages from devices back to your server over FCM’s reliable and battery-efficient connection channel.

Message types

  • Notification messages, sometimes thought of as "display messages." These are handled by the FCM SDK automatically.
{
"message":{
    "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "notification":{
    "title":"Portugal vs. Denmark",
    "body":"great match!"
    }
}
}

Notification messages have a predefined set of user-visible keys and an optional data payload of custom key-value pairs.

  • Data messages, which are handled by the client app.
{
  "message":{
    "token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "data":{
      "Nick" : "Mario",
      "body" : "great match!",
      "Room" : "PortugalVSDenmark"
    }
  }
}

Data messages have only custom key-value pairs. A message can transfer a payload of up to 4KB to a client app.

How it works?

An FCM implementation includes two main components for sending and receiving:

  • A trusted environment such as Cloud Functions for Firebase or an app server on which to build, target, and send messages and an iOS client app that receives messages.

  • You can send messages via the HTTP and XMPP APIs. For testing or for sending marketing or engagement messages with powerful built-in targeting and analytics, you can also use the Notifications composer.

Understanding Firebase Cloud Messaging on iOS

APNs

FCM

How?

Everything we need

Under the hood

Method swizzling is the process of changing the implementation of an existing selector

Connect to FCM

Restrictions

FCM Server

FCM Server Protocols

Currently FCM provides these raw server protocols:

  • FCM HTTP v1 API
  • Legacy HTTP protocol
  • Legacy XMPP Protocol

Build App Server Send Requests

Using the FCM app server protocols, you can build message requests and send them to these types of targets:

  • Topic name
  • Condition
  • Device registration token
  • Device group name (legacy protocols only)

Open sources implement FCM Server Protocols

C# / .NET

Python

GO

Ruby

Rust

Node.js

PHP

Java

About

Firebase Cloud Messaging - deliver and receive messages and notifications on iOS

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published