সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
নিম্নলিখিত উদাহরণগুলি আপনাকে অ্যান্ড্রয়েড ক্লায়েন্টে ইনস্ট্যান্স আইডি প্রয়োগ করতে সহায়তা করবে। মনে রাখবেন যে এই উদাহরণগুলি GCM স্কোপ ব্যবহার করে, যা শুধুমাত্র প্রদর্শনের উদ্দেশ্যে উপযোগী কারণ Google ক্লাউড মেসেজিং ব্যবহার থেকে অবসর নেওয়া হয়েছে।
Google Play পরিষেবাগুলি সেট আপ করুন৷
আপনার ক্লায়েন্ট অ্যাপ্লিকেশন লিখতে, Google Play পরিষেবা SDK ব্যবহার করুন, যেমনটি Google Play পরিষেবা SDK সেট আপ করুন । প্লে সার্ভিসেস লাইব্রেরিতে ইনস্ট্যান্স আইডি লাইব্রেরি রয়েছে।
একটি ইনস্ট্যান্স আইডি পান
কোডের নিম্নলিখিত লাইনটি একটি ইনস্ট্যান্স আইডি প্রদান করে:
String authorizedEntity = PROJECT_ID; // Project id from Google Developer Console String scope = "GCM"; // e.g. communicating using GCM, but you can use any // URL-safe characters up to a maximum of 1000, or // you can also leave it blank. String token = InstanceID.getInstance(context).getToken(authorizedEntity,scope);
টোকেন এবং ইনস্ট্যান্স আইডি পরিচালনা করুন
ইনস্ট্যান্স আইডি আপনাকে টোকেন মুছতে এবং রিফ্রেশ করতে দেয়।
ইনস্ট্যান্স আইডি পরিষেবাটি পর্যায়ক্রমে কলব্যাক শুরু করে (উদাহরণস্বরূপ, প্রতি 6 মাসে), অনুরোধ করে যে আপনার অ্যাপটি তার টোকেনগুলি রিফ্রেশ করে। এটি কলব্যাক শুরু করতে পারে যখন:
নিরাপত্তা সমস্যা আছে; উদাহরণস্বরূপ, SSL বা প্ল্যাটফর্ম সমস্যা।
ডিভাইস তথ্য আর বৈধ নয়; উদাহরণস্বরূপ, ব্যাকআপ এবং পুনরুদ্ধার।
ইনস্ট্যান্স আইডি পরিষেবা অন্যথায় প্রভাবিত হয়।
এই কলব্যাকগুলি পেতে আপনার অ্যাপে ইনস্ট্যান্স আইডি লিসেনার পরিষেবাটি প্রয়োগ করুন:
[[["সহজে বোঝা যায়","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-08-15 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThis documentation provides examples of how to implement Instance ID in an Android client using the Google Play services SDK.\u003c/p\u003e\n"],["\u003cp\u003eYou can get an Instance ID, generate tokens using your Project ID, and manage these tokens by deleting or refreshing them.\u003c/p\u003e\n"],["\u003cp\u003eInstance ID service may initiate callbacks for token refresh due to security issues, device information changes, or other service-related events.\u003c/p\u003e\n"],["\u003cp\u003eTo handle token refresh callbacks, implement the Instance ID listener service and configure it in your Android Manifest file.\u003c/p\u003e\n"]]],[],null,["The following examples will help you implement Instance ID in an Android\nclient. Note that these examples use the GCM scope, which is useful only\nfor demonstration purposes because\n[Google Cloud Messaging](/cloud-messaging/android/client) has been\nretired from use.\n\nSet Up Google Play Services\n\nTo write your client application, use the Google Play services SDK,\nas described in [Set up Google Play\nServices SDK](http://developer.android.com/google/play-services/setup.html). The Play Services Library includes the Instance ID library.\n\nGet an Instance ID\n\nThe following line of code returns an Instance ID: \n\n String iid = InstanceID.getInstance(context).getId();\n\nGenerate a token\n\nGenerating tokens requires a Project ID generated by the\n[Google Developers Console](https://console.developers.google.com/project). \n\n String authorizedEntity = PROJECT_ID; // Project id from Google Developer Console\n String scope = \"GCM\"; // e.g. communicating using GCM, but you can use any\n // URL-safe characters up to a maximum of 1000, or\n // you can also leave it blank.\n String token = InstanceID.getInstance(context).getToken(authorizedEntity,scope);\n\nManage tokens and Instance IDs\n\nInstance ID lets you delete and refresh tokens.\n\nDelete tokens and Instance IDs \n\n String authorizedEntity = PROJECT_ID;\n String scope = \"GCM\";\n InstanceID.getInstance(context).deleteToken(authorizedEntity,scope);\n\nYou can also delete the Instance ID itself, including all associated\ntokens. The next time you call `getInstance()` you will get a new\nInstance ID: \n\n InstanceID.getInstance(context).deleteInstanceID();\n String newIID = InstanceID.getInstance(context).getId();\n\n| **Note:** If your app used tokens that were deleted by `deleteInstanceID`, your app will need to generate replacement tokens.\n\nRefresh tokens\n\nThe Instance ID service initiates callbacks periodically (for example,\nevery 6 months), requesting that your app refreshes its tokens. It may also\ninitiate callbacks when:\n\n- There are security issues; for example, SSL or platform issues.\n- Device information is no longer valid; for example, backup and restore.\n- The Instance ID service is otherwise affected.\n\nImplement the Instance ID listener service in your app to receive these\ncallbacks: \n\n public class MyInstanceIDService extends InstanceIDListenerService {\n public void onTokenRefresh() {\n refreshAllTokens();\n }\n\n private void refreshAllTokens() {\n // assuming you have defined TokenList as\n // some generalized store for your tokens\n ArrayList\u003cTokenList\u003e tokenList = TokensList.get();\n InstanceID iid = InstanceID.getInstance(this);\n for(tokenItem : tokenList) {\n tokenItem.token =\n iid.getToken(tokenItem.authorizedEntity,tokenItem.scope,tokenItem.options);\n // send this tokenItem.token to your server\n }\n }\n };\n\nYou must also configure this service in the Manifest file for the project: \n\n \u003cservice android:name=\".MyInstanceIDService\" android:exported=\"false\"\u003e\n \u003cintent-filter\u003e\n \u003caction android:name=\"com.google.android.gms.iid.InstanceID\"/\u003e\n \u003c/intent-filter\u003e\n \u003c/service\u003e"]]