קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
תוסף Firebase מבצע משימה ספציפית או קבוצה של משימות בתגובה לבקשות HTTP או לאירועים מפעילים ממוצרי Firebase ו-Google אחרים, כמו Firebase Cloud Messaging, Cloud Firestore או Pub/Sub.
אתם יכולים ליצור תוסף משלכם לשימוש אישי או לשתף אותו עם העולם ב-Firebase Extensions Hub. לדוגמה, התוסף יכול לבצע משימה ספציפית שהאפליקציה צריכה באופן קבוע, או להקל על הגישה לאחד מממשקי ה-API של החברה. אחרי שיוצרים את התוסף, אפשר לשתף אותו עם אחרים. המשתמשים האלה יכולים להתקין ולהגדיר את התוסף לשימוש בפרויקטים שלהם ב-Firebase.
המבנה של תוסף
אפשר לחלק את התוסף לשלושה רכיבים עיקריים:
קוד של Cloud Functions ב-JavaScript או ב-TypeScript
הספרייה functions מכילה את הקוד של Cloud Functions ב-JavaScript
או ב-TypeScript. זהו הקוד שמבצע את המשימות של התוסף בתגובה לאירועים שמופעלים על ידי שירותי Firebase ו-Google.
קובץ extension.yaml מכיל מטא-נתונים על התוסף, כמו הטריגרים ותפקידי הגישה של IAM, וגם פרמטרים שאתם רוצים שהמשתמש יוכל להגדיר.
הקבצים PREINSTALL, POSTINSTALL ו-CHANGELOG הם המינימום של המסמכים שחייבים להיות לתוסף. הקבצים האלה עוזרים למשתמשים להבין מה התוסף עושה, איך להשתמש בו ואילו עדכונים ביצעתם. מומלץ גם לספק סמל כדי לעזור למשתמשים לזהות את התוסף. במסוף Firebase, ב-Firebase CLI וב-Extensions Hub מוצג התוכן של הקבצים האלה כשמשתמשים בוחנים, מתקינים ומנהלים את התוסף שלכם.
אחרי שיוצרים את התוסף, אפשר להשתמש ב-Firebase CLI כדי להתקין אותו בפרויקט או לפרסם אותו במרכז התוספים, שבו כל אחד יכול למצוא אותו ולהתקין אותו בפרויקטים שלו.
עם אילו מוצרים התוסף יכול ליצור אינטראקציה?
תוסף Firebase מבצע את העבודה שלו באמצעות Cloud Functions, ולכן אפשר לחשוב על השאלה לגבי שילובים אפשריים בשתי דרכים: אילו מוצרים יכולים להפעיל את הפונקציות של התוסף? ואחרי ההפעלה, עם אילו מוצרים יכולות הפונקציות של התוסף ליצור אינטראקציה?
טריגרים נתמכים של פונקציות
טריגרים ידניים
קודם כל, אפשר להפעיל פונקציה באופן ידני. תוספי Firebase ו-Cloud Functions תומכים בשתי דרכים להפעלת פונקציות באופן ידני:
טריגרים של HTTP: פריסת פונקציה לנקודת קצה (endpoint) של HTTP
פונקציות שאפשר להפעיל: אפשר להפעיל את Cloud Functions ישירות מקוד הלקוח של iOS, Android או האינטרנט באמצעות ערכות Firebase SDK ללקוח.
אם חושפים נקודות קצה של HTTP מהתוסף, התוסף יכול להשתלב עם כל שירות אינטרנט שתומך ב-webhook. בעזרת פונקציות שאפשר להפעיל, משתמשים שמתקינים את התוסף יכולים להשתמש ב-Firebase SDKs כספריית לקוח כדי לגשת ל-API שהתוסף מטמיע.
טריגרים של שירות Firebase
רוב המוצרים של Firebase פולטים אירועים שיכולים להפעיל את Cloud Functions של תוסף.
Analytics: הפעלת פונקציות כשמערכת Analytics מתעדת אירוע
הפצת אפליקציות: הפעלת פונקציות כשמופעלת התראה בהפצת אפליקציות
אימות: הפעלת פונקציות כשמשתמשים יוצרים ומוחקים חשבונות
Cloud Firestore: הפעלת פונקציות של טריגר כשדפים נוצרים, מתעדכנים או נמחקים
Cloud Storage: הפעלת פונקציות כשמעלים אובייקטים לקטגוריות, מעבירים אותם לארכיון או מוחקים אותם מהקטגוריות
Crashlytics: הפעלת פונקציות כש-Crashlytics מפעיל התראה
מעקב אחרי ביצועים: הפעלת פונקציות כשמעקב אחרי ביצועים מפעיל התראה
Realtime Database: הפעלת פונקציות של טריגר כשנתונים נוצרים, מתעדכנים או נמחקים
הגדרת תצורה מרחוק: הפעלת פונקציות כשפרמטר מתעדכן
Test Lab: הפעלת פונקציות כש-Test Lab מפעיל התראה
טריגרים של שירות Google Cloud
תוסף יכול לכלול גם פונקציות שמופעלות על ידי כמה שירותים של Google Cloud שאינם Firebase:
Cloud Pub/Sub: תוסף יכול לכלול פונקציות שמופעלות כשאירועים מתפרסמים בנושא Pub/Sub שניתן להגדרה.
Cloud Scheduler: תוסף יכול לכלול פונקציות שפועלות לפי לוח זמנים מוגדר
Cloud Tasks: תוסף יכול לכלול פונקציות שאפשר להוסיף לתור באמצעות Cloud Tasks. התכונה הזו מאפשרת לכם, כמפתחי תוספים, לכתוב פונקציות שמגיבות לאירועים של 'מחזור החיים' של התוסף: התקנה בפרויקט בפעם הראשונה, שדרוג לגרסה חדשה ושינוי הגדרות.
Eventarc: תוסף יכול לכלול פונקציות שמופעלות כשאירועים מתפרסמים בערוץ Eventarc שניתן להגדרה. לחלופין, תוסף יכול לפרסם אירועים משלו בערוץ Eventarc כדי לאפשר למשתמשים להגדיר פונקציות משלהם שמופעלות מאירועים של תוסף.
פונקציות נתמכות
אחרי שהופעלה פונקציית Cloud של תוסף, בדרך כלל יש מגוון רחב של שילובים אפשריים. ריכזנו כאן כמה דוגמאות לפעולות שאפשר לבצע באמצעות Cloud Functions:
קריאה, כתיבה ויצירת אינטראקציה עם כל שירות של Firebase או Google Cloud שמשתמש בתפקיד IAM נתמך.
עבודה עם כל שירות צד שלישי שמספק Web API.
עבודה עם שירותים בהתאמה אישית אם אתם מספקים API לאינטרנט.
להריץ את רוב ספריות JavaScript, כולל TensorFlow.js, Express.js וכו'.
איך יוצרים תוסף
המדריך תחילת העבודה מסביר איך ליצור, לבדוק ולפרסם תוסף מלא, והוא הדרך המומלצת ללמוד איך ליצור תוסף.
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-07-25 (שעון UTC)."],[],[],null,["\u003cbr /\u003e\n\nA Firebase Extension performs a specific task or set of tasks in response to\nHTTP requests or triggering events from other Firebase and Google products, like\nFirebase Cloud Messaging, Cloud Firestore, or Pub/Sub.\n\nYou can build your own extension for personal use or to share with the world in\nthe Firebase Extensions Hub. For example, your extension can perform a specific\ntask that your app regularly needs, or it can make it easier to access one of\nyour company's APIs. After you build your extension, you can share it with\nothers. Those users can install and configure the extension for use in their own\nFirebase projects.\n\nStructure of an extension\n\nYou can think of an extension as having three main components:\n\n- Cloud Functions code, in JavaScript or TypeScript\n- Metadata that describes your extension\n- Documentation to help your users configure and use your extension\n\nTo develop an extension, you assemble these components into the following\nstructure: \n\n example-extension\n ├── functions\n │ ├── integration-tests\n │ │ ├── extensions\n │ │ │ └── example-extension.env\n │ │ ├── firebase.json\n │ │ └── integration-test.spec.js\n │ ├── index.js\n │ └── package.json\n ├── README.md\n ├── PREINSTALL.md\n ├── POSTINSTALL.md\n ├── CHANGELOG.md\n ├── icon.png\n └── extension.yaml\n\n- The `functions` directory contains your Cloud Functions code in JavaScript or TypeScript. This is the code that performs the extension's tasks in response to events triggered by Firebase and Google services.\n- The `extension.yaml` file contains metadata about your extension, such as its triggers and IAM access roles, as well as any parameters you want to be user-configurable.\n- The `PREINSTALL`, `POSTINSTALL`, and `CHANGELOG` files are the minimum documentation your extension must have. These files help your users learn what your extension does, how to use it, and what updates you've made. You should also provide an icon to help users recognize your extension. The Firebase console, Firebase CLI, and Extensions Hub display the contents of these files when users explore, install, and manage your extension.\n\nAfter you have created your extension, you can use the Firebase CLI to install\nit into a project or publish it to the Extensions Hub, where anyone can discover\nand install it into their projects.\n\nWhat products can my extension interact with?\n\nBecause a Firebase extension does its work using Cloud Functions, you can think\nof the question of possible integrations in two ways: *What products can trigger\nmy extension's functions?* and *Once triggered, what products can my extension's\nfunctions interact with?*\n\nSupported function triggers\n\nManual triggers\n\nFirst of all, you can manually trigger a function. Firebase Extensions and Cloud\nFunctions support two ways of manually triggering functions:\n\n- HTTP triggers: deploy a function to an HTTP endpoint\n- Callable functions: call your Cloud Functions directly from your iOS, Android, or web client code, using the Firebase client SDKs.\n\nBy exposing HTTP endpoints from your extension, your extension can potentially\nintegrate with any web service that supports webhooks. With callable functions,\nusers who install your extension can use the Firebase SDKs as a client library\nfor accessing the API your extension implements.\n\nFirebase service triggers\n\nMost Firebase products emit events that can trigger an extension's Cloud\nFunctions.\n\n- **Analytics:** trigger functions when Analytics logs an event\n- **App Distribution:** trigger functions when App Distribution triggers an alert\n- **Authentication:** trigger functions when users create and delete accounts\n- **Cloud Firestore:** trigger functions when pages are created, updated, or deleted\n- **Cloud Storage**: trigger functions when objects are uploaded, archived, or deleted from buckets\n- **Crashlytics:** trigger functions when Crashlytics triggers an alert\n- **Performance Monitoring:** trigger functions when Performance Monitoring triggers an alert\n- **Realtime Database:** trigger functions when data is created, updated, or deleted\n- **Remote Config:** trigger functions when a parameter is updated\n- **Test Lab:** trigger functions when Test Lab triggers an alert\n\nGoogle Cloud service triggers\n\nAn extension can also include functions that trigger off several non-Firebase\nGoogle Cloud services:\n\n- **Cloud Pub/Sub**: an extension can include functions that trigger when events are posted to a configurable Pub/Sub topic.\n- **Cloud Scheduler**: an extension can include functions that run on a set schedule\n- **Cloud Tasks**: an extension can include functions that can be queued using Cloud Tasks. Firebase Extensions uses this capability to let you, as an extension author, write functions that respond to an extension's \"lifecycle\" events: being installed in a project for the first time, being upgraded to a new version, and being reconfigured.\n- **Eventarc** : an extension can include functions that trigger when events are published to a configurable Eventarc channel; conversely, an extension can publish its own events to an Eventarc channel in order to enable users to define their own functions that trigger from an *extension's* events.\n\nSupported from functions\n\nOnce an extension's Cloud Function has been triggered, the range of possible\nintegrations is generally open ended. Here are some highlights of what you can\ndo from a Cloud Function:\n\n- Read, write, and otherwise interact with any **Firebase** or **Google Cloud** service that uses a [supported IAM role](/docs/extensions/publishers/access#supported-roles).\n- Work with any **third-party service** that provides a web API.\n- Work with your **custom services** if you provide a web API.\n- Run most JavaScript libraries, including **TensorFlow.js** , **Express.js,** and so on.\n\nHow to build an extension\n\nThe [Get Started](/docs/extensions/publishers/get-started) tutorial walks you through\nthe process of building, testing, and publishing a complete extension, and is\nthe recommended way to learn how to build one.\n\n[Get Started](/docs/extensions/publishers/get-started)\n\nAfter you've gone through the getting started guide once, you can refer to the\nindividual topic guides, which explain each of the tasks involved in building\nyour own extension:\n\n- [Write functions for an extension](/docs/extensions/publishers/functions)\n- [Use parameters in an extension](/docs/extensions/publishers/parameters)\n- [Set up appropriate access for an extension](/docs/extensions/publishers/access)\n- [Respond to extension lifecycle events](/docs/extensions/publishers/lifecycle-events)\n- [Add user hooks to an extension](/docs/extensions/publishers/user-hooks)\n- [Create user documentation for your extension](/docs/extensions/publishers/user-documentation)\n- [Publish an extension on Extensions Hub](/docs/extensions/publishers/upload-and-publish)\n- [Complete extension.yaml reference](/docs/extensions/reference/extension-yaml)"]]