Instance ID API
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Instance ID API به شما امکان می دهد Instance ID را با برنامه Android یا iOS خود ادغام کنید. Instance ID یک شناسه منحصر به فرد برای هر نمونه از برنامه شما و مکانیزمی برای احراز هویت و مجوز اقدامات ارائه می دهد. InstanceID
عمر طولانی دارد، اما ممکن است به دلایل زیر منقضی شود:
- بازنشانی کارخانه ای دستگاه
- کاربر برنامه را حذف نصب می کند.
- کاربر "Clear Data" را در برنامه انجام می دهد.
- دستگاه برای مدت طولانی استفاده نشده است (دستگاه و منطقه زمان را تعیین می کند).
- سرویس Instance ID سوء استفاده یا خطاها را شناسایی کرده و
InstanceID
را بازنشانی می کند. - اگر برنامه مشتری شما به آن عملکرد نیاز دارد، کد سمت سرور.
سرویس Instance ID برنامه شما را از بازنشانی InstanceID
از طریق تماس با InstanceIDListenerService
مطلع میکند. اگر برنامه شما این اعلان را دریافت کرد، باید getToken()
فراخوانی کند و InstanceID
جدید را بازیابی کند و سرورهای خود را به روز کند.
از روش getToken
برای اثبات مالکیت InstanceID
و اجازه دسترسی سرورها به دادهها یا خدمات مرتبط با برنامه استفاده کنید. این روش از الگوهای OAuth2 پیروی می کند و به یک Entity و scope
authorizedEntity
نیاز دارد. authorizedEntity
می تواند شناسه پروژه یا InstanceID
دیگری باشد و خدماتی را که مجاز به استفاده از توکن تولید شده هستند را تعیین می کند. scope
، سرویس یا داده خاصی را تعیین می کند که توکن اجازه دسترسی به آن را می دهد.
درباره Instance ID API بیشتر بیاموزید:
سرور اندروید iOS
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی."],[[["\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)"]]