هذا المنتج أو هذه الميزة في حالة "قديم". لمزيد من المعلومات عن الحالة "قديمة"، يُرجى الاطّلاع على
المنتجات والميزات القديمة. لنقل البيانات إلى Places API لنظام التشغيل iOS(الإصدار الجديد)، يُرجى الاطّلاع على
دليل نقل البيانات.
الرموز المميزة للجلسة
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تستخدم ميزة "الإكمال التلقائي للأماكن" (الإصدار القديم) الرموز المميّزة للجلسات لتجميع مرحلتي طلب البحث والاختيار في عملية بحث الإكمال التلقائي التي يجريها المستخدم في جلسة منفصلة لأغراض الفوترة. تبدأ الجلسة عندما يبدأ المستخدم كتابة طلب بحث، وتنتهي
عندما يختار مكانًا ويتم إجراء مكالمة إلى "تفاصيل المكان" (الإصدار القديم). يمكن أن تحتوي كل جلسة على عدة طلبات بحث لإكمال تلقائي، يليها اختيار مكان واحد. يجب أن تكون مفاتيح واجهة برمجة التطبيقات
المستخدَمة لكل طلب ضمن جلسة واحدة تابعة لمشروع
Google Cloud Console نفسه. بعد انتهاء الجلسة، لن يعود الرمز المميّز
صالحًا، ويجب أن ينشئ تطبيقك رمزًا مميّزًا جديدًا لكل جلسة. في حال حذف المَعلمة
sessiontoken
أو إعادة استخدام رمز إشتراك
الجلسة، يتم تحصيل رسوم الجلسة كما لو لم يتم تقديم رمز إشتراك الجلسة (يتم فوترة كل طلب
بشكل منفصل).
ننصحك باتّباع الإرشادات التالية:
- استخدِم الرموز المميّزة للجلسات لجميع جلسات الملء التلقائي.
- أنشئ رمزًا مميزًا جديدًا لكل جلسة.
- تأكَّد من أنّ مفاتيح واجهة برمجة التطبيقات المستخدَمة في جميع طلبات "الإكمال التلقائي للأماكن" (القديمة) و"تفاصيل الأماكن" (القديمة)
ضمن جلسة معيّنة تنتمي إلى مشروع وحدة تحكّم Google Cloud نفسه.
- احرص على تمرير رمز مميّز للجلسة لكل جلسة جديدة. سيؤدي استخدام الرمز المميّز
نفسه لأكثر من جلسة واحدة إلى تحصيل رسوم كل طلب
على حدة.
يمكنك اختياريًا حذف رمز مفتاح جلسة الإكمال التلقائي من الطلب. في حال حذف رمز تمييز الجلسة، يتم فوترة كل طلب بشكل منفصل، ما يؤدي إلى تنشيط سمة الإكمال التلقائي لكل طلب
رمز التخزين التعريفي. في حال إعادة استخدام رمز مميّز للجلسة، تُعتبر الجلسة غير صالحة ويتم تحصيل رسوم من الطلبات كما لو لم يتم تقديم رمز مميّز للجلسة.
مثال
بينما يكتب المستخدم طلب بحث، يتمّ استدعاء طلب الإكمال التلقائي بعد كل بضع
ضغطات مفتاح (وليس لكلّ حرف)، ويتمّ عرض قائمة بالنتائج المحتمَلة.
عندما يختار المستخدم عنصرًا من قائمة النتائج، يتم احتساب هذا الاختيار على أنّه
طلب، ويتم تجميع جميع الطلبات التي تم إجراؤها أثناء البحث و
احتسابها كطلب واحد. إذا اختار المستخدم مكانًا، سيكون طلب البحث
متاحًا بدون أي رسوم، ولن يتم تحصيل رسوم إلا مقابل طلب بيانات المكان. إذا لم يُجري المستخدِم
اختيارًا خلال بضع دقائق من بدء الجلسة، يتم تحصيل رسوم عن
طلب البحث فقط.
لنطّلِع على تسلسل الأحداث هذا من منظور أحد التطبيقات.
- يبدأ أحد المستخدِمين بكتابة طلب بحث للبحث عن "باريس، فرنسا".
- عند رصد إدخال المستخدم، ينشئ التطبيق رمزًا مميّزًا جديدًا لجلسة
، وهو "الرمز المميّز (أ)".
- بينما يكتب المستخدم، تُرسل واجهة برمجة التطبيقات طلبًا للإكمال التلقائي بعد كل بضع
أحرف، وتعرض قائمة جديدة بالنتائج المحتملة لكل منها:
"P"
"Par"
"Paris,"
"Paris, Fr"
- عندما يختار المستخدم أحد الخيارات:
- يتم تجميع جميع الطلبات الناتجة عن طلب البحث وإضافتها إلى
الجلسة التي يمثّلها "الرمز المميّز أ"، كطلب واحد.
- يتم احتساب اختيار المستخدم كطلب لتفاصيل مكان، ويتمّ إضافته
إلى الجلسة التي يمثّلها "الرمز المميّز (أ)".
- تنتهي الجلسة، ويتخلّص التطبيق من "الرمز المميّز أ".
لمزيد من المعلومات عن كيفية فوترة طلبات ميزة "الإكمال التلقائي للأماكن" (الإصدار القديم)، يُرجى الاطّلاع على الاستخدام والفوترة.
إنشاء الرموز المميّزة للجلسات
لإنشاء رمز مميّز للجلسة، اتصل بالرقم
GMSAutocompleteSessionToken.init()
.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Session Tokens\n\nSelect platform: [Android](/maps/documentation/places/android-sdk/session-tokens \"View this page for the Android platform docs.\") [iOS](/maps/documentation/places/ios-sdk/session-tokens \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/places-autocomplete#session_tokens \"View this page for the JavaScript platform docs.\") [Web Service](/maps/documentation/places/web-service/session-tokens \"View this page for the Web Service platform docs.\")\n\nPlace Autocomplete (Legacy) uses session tokens to group the query and selection\nphases of a user autocomplete search into a discrete session for billing\npurposes. The session begins when the user starts typing a query, and concludes\nwhen they select a place and a call to Place Details (Legacy) is made. Each session can\nhave multiple autocomplete queries, followed by one place selection. The API\nkey(s) used for each request within a session must belong to the same\nGoogle Cloud console project. Once a session has concluded, the token is no longer\nvalid; your app must generate a fresh token for each session. If the\n`sessiontoken` parameter is omitted, or if you reuse a session\ntoken, the session is charged as if no session token was provided (each request\nis billed separately).\n\nWe recommend the following guidelines:\n\n- Use session tokens for all autocomplete sessions.\n- [Generate a fresh token](#create-session-tokens) for each session.\n- Ensure that the API key(s) used for all Place Autocomplete (Legacy) and Place Details (Legacy) requests within a session belong to the same Google Cloud console project.\n- Be sure to pass a unique session token for each new session. Using the same token for more than one session will result in each request being billed individually.\n\nYou can optionally omit the autocomplete session token from a request. If\nthe session token is omitted, each request is billed separately, triggering the\n\n[Autocomplete - Per Request](/maps/billing-and-pricing/sku-details#autocomplete-request-new-ess-sku)\n\n\nSKU. If you reuse a session token, the session is considered invalid and the\nrequests are charged as if no session token was provided.\n\nExample\n-------\n\nAs the user types a query, an autocomplete request is called every few\nkeystrokes (not per-character), and a list of possible results is returned.\nWhen the user makes a selection from the result list, the selection counts as\na request, and all of the requests made during the search are bundled and\ncounted as a single request. If the user selects a place, the search query is\navailable at no charge, and only the Place data request is charged. If the user does not make a\nselection within a few minutes of the beginning of the session, only the\nsearch query is charged.\n\nLet's examine this flow of events from the perspective of an app.\n\n1. A user begins typing a query to search for \"Paris, France\".\n2. Upon detecting user input, the app creates a new session token, \"Token A\".\n3. As the user types, the API makes an autocomplete request every few characters, displaying a new list of potential results for each: \n \"P\" \n \"Par\" \n \"Paris,\" \n \"Paris, Fr\" \n4. When the user makes a selection:\n - All requests resulting from the query are grouped and added to the session represented by \"Token A\", as a single request.\n - The user's selection is counted as a Place Detail request, and added to the session represented by \"Token A\".\n5. The session is concluded, and the app discards \"Token A\".\n\nFor more information about how Place Autocomplete (Legacy) requests are billed, see\n\n[Usage and Billing](/maps/documentation/places/ios-sdk/usage-and-billing).\n\nCreate session tokens\n---------------------\n\n\nTo create a session token, call\n[`GMSAutocompleteSessionToken.init()`](/maps/documentation/places/ios-sdk/reference/interface_g_m_s_autocomplete_session_token)."]]