API של מזהה מופע
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Instance ID API מאפשר לכם לשלב מזהה מופע עם אפליקציית Android או iOS. מזהה המופע מספק מזהה ייחודי לכל מופע של האפליקציה ומנגנון לאימות ולאישור פעולות. ה-InstanceID
הוא לטווח ארוך, אבל יכול להיות שהוא יפוג מהסיבות הבאות:
- איפוס המכשיר להגדרות המקוריות.
- המשתמש מסיר את האפליקציה.
- המשתמש מבצע 'ניקוי נתונים' באפליקציה.
- המכשיר לא היה בשימוש במשך תקופה ממושכת (משך הזמן נקבע לפי המכשיר והאזור).
- שירות Instance ID מזהה ניצול לרעה או שגיאות ומאפס את הערך של
InstanceID
.
- קוד בצד השרת אם אפליקציית הלקוח שלכם דורשת את הפונקציונליות הזו.
שירות מזהה המופע מודיע לאפליקציה על איפוס של InstanceID
באמצעות קריאה חוזרת אל InstanceIDListenerService
. אם האפליקציה מקבלת את ההתראה הזו, היא צריכה להתקשר אל getToken()
, לאחזר את InstanceID
החדש ולעדכן את השרתים שלה.
משתמשים בשיטה getToken
כדי להוכיח את הבעלות על InstanceID
וכדי לאפשר לשרתים לגשת לנתונים או לשירותים שמשויכים לאפליקציה. השיטה מבוססת על דפוסי OAuth2, ונדרשים בה authorizedEntity
ו-scope
. הערך של authorizedEntity
יכול להיות מזהה פרויקט או InstanceID
אחר, והוא קובע אילו שירותים מורשים להשתמש באסימון שנוצר. הפרמטר scope
קובע את השירות או הנתונים הספציפיים שהאסימון מאפשר גישה אליהם.
מידע נוסף על Instance ID API ל:
Android
iOS
Server
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-09-05 (שעון UTC).
[null,null,["עדכון אחרון: 2025-09-05 (שעון UTC)."],[[["\u003cp\u003eThe Instance ID API provides a unique identifier for each app instance and enables authentication and authorization.\u003c/p\u003e\n"],["\u003cp\u003eInstance IDs are long-lived but can expire due to various factors like device reset, uninstallation, data clearing, extended inactivity, or service-detected issues.\u003c/p\u003e\n"],["\u003cp\u003eUpon Instance ID reset, apps are notified and must retrieve a new ID using \u003ccode\u003egetToken()\u003c/code\u003e and update their servers.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetToken()\u003c/code\u003e method, using OAuth2 patterns, verifies Instance ID ownership and grants server access to associated data or services based on authorized entity and scope.\u003c/p\u003e\n"]]],[],null,["# Instance ID API\n\nThe Instance ID API lets you integrate Instance ID with your Android\nor iOS app. Instance ID provides a unique identifier for each instance of\nyour app and a mechanism to authenticate and authorize actions. The `InstanceID` is long\nlived, but may expire for the following reasons:\n\n- Device factory reset.\n- User uninstalls the app.\n- User performs \"Clear Data\" in the app.\n- Device unused for an extended period (device and region determines the timespan).\n- Instance ID service detects abuse or errors and resets the `InstanceID`.\n- Server-side code if your client app requires that functionality.\n\nThe Instance ID service notifies your app of an `InstanceID` reset via\ncallback to a `InstanceIDListenerService`. If your app receives this\nnotification, it must call `getToken()` and retrieve the new `InstanceID`,\nand update its servers.\n\nUse the `getToken` method to prove the ownership of the `InstanceID` and to allow\nservers to access data or services associated with the app. The method follows\nthe patterns of OAuth2, and requires an `authorizedEntity` and `scope`. The\n`authorizedEntity` can be a project ID or another `InstanceID`, and it determines\nthe services that are authorized to use the generated token. The `scope`\ndetermines the specific service or data to which the token allows access.\n\nLearn more about the Instance ID API for:\n\n[Android](/instance-id/reference/android/api)\n[iOS](/instance-id/reference/ios/api)\n[Server](/instance-id/reference/server)"]]