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
1from apify_client import ApifyClient
2
3# Initialize the ApifyClient with your Apify API token
4client = ApifyClient("<YOUR_API_TOKEN>")
5
6# Prepare the Actor input
7run_input = {
8 "serviceAccountKey": """{
9 \"type\": \"service_account\",
10 \"project_id\": \"your-project-id\",
11 \"private_key_id\": \"someprivatekeyid1234567890abcdef\",
12 \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASC...\\n-----END PRIVATE KEY-----\\n\",
13 \"client_email\": \"firebase-adminsdk-abcde@your-project-id.iam.gserviceaccount.com\",
14 \"client_id\": \"123456789012345678901\",
15 \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",
16 \"token_uri\": \"https://oauth2.googleapis.com/token\",
17 \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",
18 \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-abcde%40your-project-id.iam.gserviceaccount.com\"
19}
20""",
21 "notification": {
22 "title": "Title",
23 "body": "Hello, world!",
24 },
25}
26
27# Run the Actor and wait for it to finish
28run = client.actor("martin.forejt/send-fcm").call(run_input=run_input)
29
30# Fetch and print Actor results from the run's dataset (if there are any)
31print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
32for item in client.dataset(run["defaultDatasetId"]).iterate_items():
33 print(item)
34
35# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start
Developer
Maintained by Community
Actor metrics
- 4 monthly users
- 3 stars
- 33.3% runs succeeded
- Created in Aug 2024
- Modified 5 days ago
Categories