Url: https://console.firebase.google.com/
Press "Add app"
button (android, ios, webapp)
- Firebase config for clients:
Project settings
>General
>Your apps
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.15.0/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/7.15.0/firebase-analytics.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "<<FCM_API_KEY>>",
authDomain: "<<FCM_AUTH_DOMAIN>>.firebaseapp.com",
databaseURL: "https://<<FCM_DATABASE_URL>>.firebaseio.com",
projectId: "<<FCM_PROJECT_ID>>",
storageBucket: "<<FCM_STORAGE_BUCKET>>.appspot.com",
messagingSenderId: "<<FCM_MESSAGING_SENDER_ID>>",
appId: "<<FCM_APP_ID>>",
measurementId: "<<FCM_MEASUREMENT_ID>>"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
- Server key to the server side
Key Token
Server key <<FCM_SERVER_KEY>>
"Based on the publish/subscribe model, FCM topic messaging allows you to send a message to multiple devices that have opted in to a particular topic. You compose topic messages as needed, and FCM handles routing and delivering the message reliably to the right devices."
Steps:
- Url: https://console.cloud.google.com/
- Select a project
- Select
Pub/Sub
- url: https://console.cloud.google.com/cloudpubsub/topic/
- or menu:
Big Data
>Pub/Sub
>Topics
- Client:
- copy
firebase-messaging-sw.js
in the root of your domain - change the config (
<<FCM_API_KEY>>
,<<FCM_AUTH_DOMAIN>>
, etc.) infirebase-messaging-sw.js
andclient.html
files
- copy
- Server:
- change the
<<FCM_SERVER_KEY>>
value in theserver.php
file
- change the
Server implementation is optional. Use the Instance ID service if you want to perform these operations:
- Get information about app instances. Verify app tokens or get more information about the app instance that created the token.
- Create relationship maps for app instances. Create relationships between app instances and entities such as FCM or GCM topics.
- Create registration tokens for APNs tokens. This API lets you bulk import existing APNs tokens, mapping them to valid registration tokens for FCM or GCM.
- Manage registration tokens for push subscriptions. For web applications implemented using the Push API, import your existing push subscriptions, mapping them to valid registration tokens for FCM.
-
Get information about app instances
- Request:
GET
- Url:
https://iid.googleapis.com/iid/info/<<IID_TOKEN>>
- Headers:
- Key:
Authorization
- Value:
key=<<FCM_SERVER_KEY>>
- Key:
- Request:
-
Create a relation mapping for an app instance
- Request:
POST
- Url:
https://iid.googleapis.com/iid/v1/<<IID_TOKEN>>/rel/topics/<<TOPIC_NAME>>
- Headers:
- Key:
Authorization
- Value:
key=<<FCM_SERVER_KEY>>
- Key:
- Request:
- Firebase (console)
- Fireabase (github)
- Firebase (docs)
- Firebase cloud messaging (docs)
- Firebase live (youtbe channel)
- Firebase Admin SDK for PHP (github)
- Firebase Admin SDK for PHP (docs)
- What is Instance ID? (Google developers)
- Instance ID > Server Reference
- Web Push Book
- Web fundamentals - Adding Push Notifications to a Web App
- PHP-FCM Documentation
- Full list of predefined keys available for building notification messages