فئة استراتيجية GNS
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
الإستراتيجية المستخدمة لاكتشاف الأجهزة المجاورة.
تكتسب NSObject.
|
GNSDiscoveryMode | discoveryMode |
| لاكتشاف الأجهزة المجاورة، يجب أن يبث أحد الجهازين رمز إقران وأن يبحث الجهاز الآخر عن رموز الإقران. المزيد...
|
|
GNSDiscoveryMediums | discoveryMediums |
| تتحكّم هذه السياسة في الوسائط التي يمكن استخدامها لبث رموز الإقران ومسحها ضوئيًا عند رصد الأجهزة المجاورة. المزيد...
|
|
BOOL | allowInBackground |
| حاوِل استخدام استراتيجية استكشاف المحتوى عندما يكون التطبيق مفعّلاً في الخلفية. المزيد...
|
|
+ (instancetype) strategy |
|
|
|
تعرض الاستراتيجية التلقائية التي تستخدِم القيم التلقائية لجميع المواقع.
تعرِض استراتيجية مخصّصة. يمكنك ضبط أي من السمات الاختيارية في paramsBlock
.
- (GNSDiscoveryMode) discoveryMode |
|
readnonatomicassign |
لاكتشاف الأجهزة المجاورة، يجب أن يبث أحد الجهازين رمز إقران وأن يبحث الجهاز الآخر عن رموز الإقران.
ونظرًا لعدم وجود طريقة لإجراء المفاوضات مسبقًا، يكون الإعداد التلقائي هو أن يتم بث المحتوى وفحصه على جميع الأجهزة.
تتيح لك هذه الخاصية تخصيص هذا السلوك، ما يؤدي إلى قصر عمل التطبيق على البث أو المسح الضوئي. على سبيل المثال، ضع في اعتبارك تطبيقًا للهاتف المحمول يتصل بجهاز فك التشفير. إذا تمت برمجة جهاز الاستقبال عن طريق بث رمز إقران، يمكن ضبط تطبيق الجوّال على البحث فقط، لتحسين وقت الاستجابة.
والقيمة التلقائية هي kGNSDiscoveryModeDefault
.
- (GNSDiscoveryMediums) discoveryMediums |
|
readnonatomicassign |
تتحكّم هذه السياسة في الوسائط التي يمكن استخدامها لبث رموز الإقران ومسحها ضوئيًا عند رصد الأجهزة المجاورة.
يمكنك الانتقال إلى discoveryMode
للحصول على مزيد من التفاصيل حول اكتشاف الأجهزة.
والقيمة التلقائية هي kGNSDiscoveryMediumsDefault
.
- (BOOL) allowInBackground |
|
readnonatomicassign |
حاوِل استخدام استراتيجية استكشاف المحتوى عندما يكون التطبيق مفعّلاً في الخلفية.
تجدر الإشارة إلى أنّه لن يُسمح بتشغيل جميع الاستراتيجيات في الخلفية. يمكنك طلب ذلك هنا، واستنادًا إلى الإعدادات والظروف الأخرى، قد يُسمح بمواصلة الاستراتيجية في الخلفية. لا تتوفَّر في الوقت الحالي سوى عمليات الفحص أو البثّ بتقنية البلوتوث المنخفض الطاقة (BLE).
والقيمة التلقائية هي NO
.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-08-13 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-13 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eThe \u003ccode\u003eGNSStrategy\u003c/code\u003e class defines the approach for discovering nearby devices, encompassing discovery mode, mediums, and background operation.\u003c/p\u003e\n"],["\u003cp\u003eYou can obtain a default strategy with preset configurations or customize a strategy by specifying properties using a params block.\u003c/p\u003e\n"],["\u003cp\u003eFor device discovery, one device broadcasts a pairing code, and the other scans; you can customize this behavior by setting the \u003ccode\u003ediscoveryMode\u003c/code\u003e property.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ediscoveryMediums\u003c/code\u003e property allows controlling the communication channels (e.g., Bluetooth, ultrasound) used for discovering nearby devices.\u003c/p\u003e\n"],["\u003cp\u003eWhile the default setting disallows background operation, you can request background execution for the discovery strategy using \u003ccode\u003eallowInBackground\u003c/code\u003e, although it's not always guaranteed.\u003c/p\u003e\n"]]],[],null,["# GNSStrategy Class\n\n[Class Methods](#pub-static-methods) \\| [Properties](#properties) \nGNSStrategy Class Reference \n\nOverview\n--------\n\nThe strategy to use to detect nearby devices.\n\nInherits NSObject.\n\n|----------------|---------------------------------------------------------------------------------------------------------------------------------------|\n| Class Method Summary -------------------- ||\n| (instancetype) | + [strategy](/nearby/messages/ios/reference/interface_g_n_s_strategy#afc67e9c07852a35945a13998bac050ed) |\n| | Returns the default strategy, which uses the default values for all properties. [More...](#afc67e9c07852a35945a13998bac050ed) |\n| ||\n| (instancetype) | + [strategyWithParamsBlock:](/nearby/messages/ios/reference/interface_g_n_s_strategy#af97d06481398cf1e5d7f2f8b54026966) |\n| | Returns a custom strategy. You can set any of the optional properties in `paramsBlock`. [More...](#af97d06481398cf1e5d7f2f8b54026966) |\n| ||\n\n|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Property Summary ---------------- ||\n| GNSDiscoveryMode | [discoveryMode](/nearby/messages/ios/reference/interface_g_n_s_strategy#ad10088af20c44daa2d29f9099b9d6422) |\n| | For nearby device discovery, one device must broadcast a pairing code and the other device must scan for pairing codes. [More...](#ad10088af20c44daa2d29f9099b9d6422) |\n| ||\n| GNSDiscoveryMediums | [discoveryMediums](/nearby/messages/ios/reference/interface_g_n_s_strategy#ad9b6ae317c7ba8ba3ca9da28f831ae0a) |\n| | Controls which mediums to use to broadcast and scan pairing codes when discovering nearby devices. [More...](#ad9b6ae317c7ba8ba3ca9da28f831ae0a) |\n| ||\n| BOOL | [allowInBackground](/nearby/messages/ios/reference/interface_g_n_s_strategy#a4794a869b9225cca308c30e40905f39c) |\n| | Try to use the discovery strategy when the app is in the background. [More...](#a4794a869b9225cca308c30e40905f39c) |\n| ||\n\nMethod Detail\n-------------\n\n|---------------------------|---|---|---|\n| + (instancetype) strategy | | | |\n\nReturns the default strategy, which uses the default values for all properties. \n\n|-------------------------------------------|---|----------------------------------------------------------------------------------------------------|---------------|---|\n| + (instancetype) strategyWithParamsBlock: | | (void(\\^)([GNSStrategyParams](/nearby/messages/ios/reference/interface_g_n_s_strategy_params) \\*)) | *paramsBlock* | |\n\nReturns a custom strategy. You can set any of the optional properties in `paramsBlock`.\n\nProperty Detail\n---------------\n\n|-------------------------------------------------------------------------------|---------------------|\n| |------------------------------------| | - (GNSDiscoveryMode) discoveryMode | | readnonatomicassign |\n\nFor nearby device discovery, one device must broadcast a pairing code and the other device must scan for pairing codes.\n\nBecause there is no way to negotiate beforehand, the default is for all devices to both broadcast and scan.\n\nThis property lets you customize this behavior, restricting your app to either broadcast or scan. For example, consider a mobile app that communicates with a set-top box. If the set-top box is programmed to broadcast a pairing code, the mobile app could be set to scan only, to improve latency.\n\nThe default is `kGNSDiscoveryModeDefault`. \n\n|-------------------------------------------------------------------------------------------|---------------------|\n| |------------------------------------------| | - (GNSDiscoveryMediums) discoveryMediums | | readnonatomicassign |\n\nControls which mediums to use to broadcast and scan pairing codes when discovering nearby devices.\n\nSee `discoveryMode` for more details about device discovery.\n\nThe default is `kGNSDiscoveryMediumsDefault`. \n\n|---------------------------------------------------------------|---------------------|\n| |----------------------------| | - (BOOL) allowInBackground | | readnonatomicassign |\n\nTry to use the discovery strategy when the app is in the background.\n\nNote that not all strategies will be permitted to run in the background. You can request this here, and depending on other settings and circumstances, the strategy might be allowed to continue in the background. Currently only BLE scans/broadcasts are supported.\n\nThe default is `NO`."]]