ระดับ GNSBeaconStrategy
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
กลยุทธ์ที่ใช้ในการสแกนหาบีคอน
รับค่า NSObject
+ (instancetype) strategy |
|
|
|
แสดงกลยุทธ์เริ่มต้น ซึ่งใช้ค่าเริ่มต้นสำหรับพร็อพเพอร์ตี้ทั้งหมด
แสดงกลยุทธ์ที่กำหนดเอง คุณตั้งค่าพร็อพเพอร์ตี้ที่ไม่บังคับใดก็ได้ใน paramsBlock
สแกนหา iBeacons ใกล้เคียงด้วย
โดยมีค่าเริ่มต้นเป็น YES
การสแกนหา iBeacons จะทริกเกอร์กล่องโต้ตอบสิทธิ์เข้าถึงตำแหน่งจาก iOS ดังนั้นคุณจึงควรตั้งค่านี้เป็น NO
หากไม่ต้องการสแกนหา iBeacons
- (BOOL) allowInBackground |
|
readnonatomicassign |
ลองสแกนหาบีคอนเมื่อแอปทำงานอยู่เบื้องหลัง
โดยมีค่าเริ่มต้นเป็น NO
- (BOOL) lowPowerPreferred |
|
readnonatomicassign |
โหมดใช้พลังงานต่ำใช้งานได้เมื่อสแกนหาบีคอนของ Eddystone เท่านั้น และระบบจะไม่สนใจเมื่อ iBeacons รวมอยู่ด้วย
ปิดโหมดใช้พลังงานต่ำหากต้องการการสแกนเวลาในการตอบสนองต่ำลงและใช้พลังงานแบตเตอรี่ที่สูงขึ้น
โดยมีค่าเริ่มต้นเป็น YES
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-13 UTC
[null,null,["อัปเดตล่าสุด 2025-08-13 UTC"],[[["\u003cp\u003eThe \u003ccode\u003eGNSBeaconStrategy\u003c/code\u003e class defines the strategy used to scan for nearby beacons, including iBeacons and Eddystone beacons.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods for creating default and custom strategies, allowing control over scan behavior like background scanning and power usage.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eincludeIBeacons\u003c/code\u003e property determines whether to scan for iBeacons alongside Eddystone beacons, requiring location permissions if enabled.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eallowInBackground\u003c/code\u003e enables scanning while the app is in the background, while \u003ccode\u003elowPowerPreferred\u003c/code\u003e prioritizes lower battery consumption when scanning for Eddystone beacons only.\u003c/p\u003e\n"]]],[],null,["# GNSBeaconStrategy Class\n\n[Class Methods](#pub-static-methods) \\| [Properties](#properties) \nGNSBeaconStrategy Class Reference \n\nOverview\n--------\n\nThe strategy to use to scan for beacons.\n\nInherits NSObject.\n\n|----------------|---------------------------------------------------------------------------------------------------------------------------------------|\n| Class Method Summary -------------------- ||\n| (instancetype) | + [strategy](/nearby/messages/ios/reference/interface_g_n_s_beacon_strategy#adb20ee9c949a83bb6b40f298afc8d18c) |\n| | Returns the default strategy, which uses the default values for all properties. [More...](#adb20ee9c949a83bb6b40f298afc8d18c) |\n| ||\n| (instancetype) | + [strategyWithParamsBlock:](/nearby/messages/ios/reference/interface_g_n_s_beacon_strategy#ae4369cbfc0033043904d608a941ffab9) |\n| | Returns a custom strategy. You can set any of the optional properties in `paramsBlock`. [More...](#ae4369cbfc0033043904d608a941ffab9) |\n| ||\n\n|------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Property Summary ---------------- ||\n| BOOL | [includeIBeacons](/nearby/messages/ios/reference/interface_g_n_s_beacon_strategy#a760bff5c7b04f6aca45f5eb1b00f64d6) |\n| | Scan also for nearby iBeacons. [More...](#a760bff5c7b04f6aca45f5eb1b00f64d6) |\n| ||\n| BOOL | [allowInBackground](/nearby/messages/ios/reference/interface_g_n_s_beacon_strategy#a78563e40e80e958da3381600240063d7) |\n| | Try to scan for beacons when the app is in the background. [More...](#a78563e40e80e958da3381600240063d7) |\n| ||\n| BOOL | [lowPowerPreferred](/nearby/messages/ios/reference/interface_g_n_s_beacon_strategy#a24d256ff2f7cf627b539534bb0a1241d) |\n| | Low power mode is available when scanning for Eddystone beacons only; it is ignored when iBeacons are included. [More...](#a24d256ff2f7cf627b539534bb0a1241d) |\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(\\^)([GNSBeaconStrategyParams](/nearby/messages/ios/reference/interface_g_n_s_beacon_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| |--------------------------| | - (BOOL) includeIBeacons | | readnonatomicassign |\n\nScan also for nearby iBeacons.\n\nThe default is `YES`. Scanning for iBeacons triggers a location permission dialog from iOS, so you should set this to `NO` if you don't want to scan for iBeacons. \n\n|---------------------------------------------------------------|---------------------|\n| |----------------------------| | - (BOOL) allowInBackground | | readnonatomicassign |\n\nTry to scan for beacons when the app is in the background.\n\nThe default is `NO`. \n\n|---------------------------------------------------------------|---------------------|\n| |----------------------------| | - (BOOL) lowPowerPreferred | | readnonatomicassign |\n\nLow power mode is available when scanning for Eddystone beacons only; it is ignored when iBeacons are included.\n\nTurn off low power mode if you prefer lower latency scanning, at a higher battery cost.\n\nThe default is `YES`."]]