Send FCM
Under maintenanceTry for free
No credit card required
View all Actors
This Actor may be unreliable while under maintenance. Would you like to try a similar Actor instead?
See alternative ActorsSend FCM
martin.forejt/send-fcm
Try for free
No credit card required
This actor can be used as integration with Firebase Cloud Messaging (FCM). It sends a message (aka push notification) to a device, group of devices or topics. The message can be fully customised supporting all FCM options.
The code examples below show how to run the Actor and get its results. To run the code, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token, which you can find under Settings > Integrations in Apify Console. Learn more
1import { ApifyClient } from 'apify-client';
2
3// Initialize the ApifyClient with your Apify API token
4const client = new ApifyClient({
5 token: '<YOUR_API_TOKEN>',
6});
7
8// Prepare Actor input
9const input = {
10 "serviceAccountKey": `{
11 "type": "service_account",
12 "project_id": "your-project-id",
13 "private_key_id": "someprivatekeyid1234567890abcdef",
14 "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASC...\n-----END PRIVATE KEY-----\n",
15 "client_email": "firebase-adminsdk-abcde@your-project-id.iam.gserviceaccount.com",
16 "client_id": "123456789012345678901",
17 "auth_uri": "https://accounts.google.com/o/oauth2/auth",
18 "token_uri": "https://oauth2.googleapis.com/token",
19 "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
20 "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-abcde%40your-project-id.iam.gserviceaccount.com"
21 }`,
22 "notification": {
23 "title": "Title",
24 "body": "Hello, world!"
25 }
26};
27
28(async () => {
29 // Run the Actor and wait for it to finish
30 const run = await client.actor("martin.forejt/send-fcm").call(input);
31
32 // Fetch and print Actor results from the run's dataset (if any)
33 console.log('Results from dataset');
34 console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
35 const { items } = await client.dataset(run.defaultDatasetId).listItems();
36 items.forEach((item) => {
37 console.dir(item);
38 });
39})();
40
41// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs
Developer
Maintained by Community
Actor metrics
- 4 monthly users
- 3 stars
- 33.3% runs succeeded
- Created in Aug 2024
- Modified 5 days ago
Categories