คลาส GNSSubscriptionParams
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
พารามิเตอร์ที่ไม่บังคับสำหรับการสมัครใช้บริการ
ดูคําอธิบายของพารามิเตอร์แต่ละรายการได้ในการประกาศพร็อพเพอร์ตี้ด้านล่าง
รับค่า NSObject
- (GNSDeviceTypes) deviceTypesToDiscover |
|
readwritenonatomicassign |
ประเภทของอุปกรณ์ที่ค้นพบ
โดยมีค่าเริ่มต้นเป็น kGNSDeviceUsingNearby
- (NSString*) messageNamespace |
|
readwritenonatomicassign |
เนมสเปซของข้อความที่จะจับคู่
สตริงว่างคือเนมสเปซเริ่มต้น และเป็นแบบส่วนตัวสำหรับแต่ละแอป (หรือแอปที่แชร์โปรเจ็กต์ Google Developer Console)
ประเภทข้อความที่จะจับคู่ ต้องไม่เป็นค่าว่าง สตริงว่างคือประเภทเริ่มต้น
กลยุทธ์ที่จะใช้เพื่อค้นหาอุปกรณ์ที่อยู่ใกล้เคียง (ที่ไม่ใช่บีคอน)
กลยุทธ์ที่จะใช้สำหรับการสแกนบีคอน
- (GNSOperationStatusHandler) statusHandler |
|
readwritenonatomiccopy |
เครื่องจัดการสำหรับสถานะการสมัครใช้บริการ
คุณใช้รหัสนี้เพื่อติดตามสถานะของการสมัครใช้บริการที่สร้างขึ้นใหม่ได้
- (GNSPermissionRequestHandler) permissionRequestHandler |
|
readwritenonatomiccopy |
เครื่องจัดการสำหรับขอสิทธิ์จากผู้ใช้ในการใช้ใกล้เคียง
ตัวแฮนเดิลนี้จะลบล้างกล่องโต้ตอบเริ่มต้นที่ Nearby ใช้เพื่อ ถ้าคุณระบุตัวแฮนเดิลนี้ Nearby จะไม่แสดงกล่องโต้ตอบสิทธิ์
ในเครื่องจัดการคำขอ คุณควรขอสิทธิ์ของผู้ใช้เพื่อดำเนินงานที่ต้องใช้ใกล้เคียง พร้อมอธิบายเหตุผลที่ต้องใช้ เมื่อผู้ใช้ให้หรือปฏิเสธความยินยอม คุณต้องเรียกใช้การบล็อกที่ส่งผ่านไปยังเครื่องจัดการคำขอของคุณ หากคุณส่งผ่าน YES
เข้าไปในการบล็อก หมายความว่าผู้ใช้ได้ยินยอมให้ใกล้เคียงทำงานได้ หากสอบผ่านNO
หมายความว่าผู้ใช้ยังไม่ให้ความยินยอม สื่อเผยแพร่และการสมัครใช้บริการจะไม่ทำงานจนกว่าจะได้รับความยินยอม
นอกจากนี้ เครื่องจัดการยังใช้เป็นวิธี "การตรวจสอบล่วงหน้า" สำหรับกล่องโต้ตอบสิทธิ์ iOS ได้ด้วย คุณใช้รายงานนี้เพื่ออธิบายสาเหตุที่ผู้ใช้ต้องให้ความยินยอมแก่ iOS ก่อนที่แอปจะสามารถใช้ฟังก์ชันที่เกี่ยวข้องกับใกล้เคียงได้
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-13 UTC
[null,null,["อัปเดตล่าสุด 2025-08-13 UTC"],[[["\u003cp\u003e\u003ccode\u003eGNSSubscriptionParams\u003c/code\u003e provides optional parameters for customizing Nearby Messages subscriptions.\u003c/p\u003e\n"],["\u003cp\u003eParameters include device types, message namespace and type, discovery strategies, and handlers for status and permissions.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003estrategy\u003c/code\u003e property controls discovery of Nearby devices, while \u003ccode\u003ebeaconStrategy\u003c/code\u003e is for beacon scanning.\u003c/p\u003e\n"],["\u003cp\u003eYou can define handlers to monitor subscription status and manage user permission requests for Nearby.\u003c/p\u003e\n"],["\u003cp\u003eDefault values are provided for most parameters, simplifying basic subscription setup.\u003c/p\u003e\n"]]],[],null,["# GNSSubscriptionParams Class\n\n[Properties](#properties) \nGNSSubscriptionParams Class Reference \n\nOverview\n--------\n\nOptional parameters for a subscription.\n\nSee the property declarations below for explanations of each parameter.\n\nInherits NSObject.\n\n|----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|\n| Property Summary ---------------- ||\n| GNSDeviceTypes | [deviceTypesToDiscover](/nearby/messages/ios/reference/interface_g_n_s_subscription_params#aa972c219c7211e4a7c5fa785d0b11274) |\n| | The types of devices to discover. [More...](#aa972c219c7211e4a7c5fa785d0b11274) |\n| ||\n| NSString \\* | [messageNamespace](/nearby/messages/ios/reference/interface_g_n_s_subscription_params#a70e97d712c8bc53a7f9076055a91256a) |\n| | The message namespace to match. [More...](#a70e97d712c8bc53a7f9076055a91256a) |\n| ||\n| NSString \\* | [type](/nearby/messages/ios/reference/interface_g_n_s_subscription_params#a86a3f486660ee32e5824b03fcef62533) |\n| | The message type to match. Must not be nil. The empty string is the default type. [More...](#a86a3f486660ee32e5824b03fcef62533) |\n| ||\n| [GNSStrategy](/nearby/messages/ios/reference/interface_g_n_s_strategy) \\* | [strategy](/nearby/messages/ios/reference/interface_g_n_s_subscription_params#a20f64cb0cfd8890f640536dfb586e814) |\n| | The strategy to use for discovering Nearby devices (non-beacons). [More...](#a20f64cb0cfd8890f640536dfb586e814) |\n| ||\n| [GNSBeaconStrategy](/nearby/messages/ios/reference/interface_g_n_s_beacon_strategy) \\* | [beaconStrategy](/nearby/messages/ios/reference/interface_g_n_s_subscription_params#a2a2c2aecb81fef6ff47fc4204110f6da) |\n| | The strategy to use for beacon scanning. [More...](#a2a2c2aecb81fef6ff47fc4204110f6da) |\n| ||\n| GNSOperationStatusHandler | [statusHandler](/nearby/messages/ios/reference/interface_g_n_s_subscription_params#afb1a6c67329810c58745f2f4625240cc) |\n| | A handler for subscription status. [More...](#afb1a6c67329810c58745f2f4625240cc) |\n| ||\n| GNSPermissionRequestHandler | [permissionRequestHandler](/nearby/messages/ios/reference/interface_g_n_s_subscription_params#ac037a18632caddcdb730bdb2a0f9c1b1) |\n| | A handler for requesting user permission to use Nearby. [More...](#ac037a18632caddcdb730bdb2a0f9c1b1) |\n| ||\n\nProperty Detail\n---------------\n\n|-------------------------------------------------------------------------------------------|--------------------------|\n| |------------------------------------------| | - (GNSDeviceTypes) deviceTypesToDiscover | | readwritenonatomicassign |\n\nThe types of devices to discover.\n\nThe default is `kGNSDeviceUsingNearby`. \n\n|-------------------------------------------------------------------------|--------------------------|\n| |---------------------------------| | - (NSString\\*) messageNamespace | | readwritenonatomicassign |\n\nThe message namespace to match.\n\nThe empty string is the default namespace, and is private to each app (or apps sharing a Google Developer Console project). \n\n|-------------------------------------------------|--------------------------|\n| |---------------------| | - (NSString\\*) type | | readwritenonatomicassign |\n\nThe message type to match. Must not be nil. The empty string is the default type. \n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------|\n| |---------------------------------------------------------------------------------------| | - ([GNSStrategy](/nearby/messages/ios/reference/interface_g_n_s_strategy)\\*) strategy | | readwritenonatomicassign |\n\nThe strategy to use for discovering Nearby devices (non-beacons). \n\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------|\n| |----------------------------------------------------------------------------------------------------------| | - ([GNSBeaconStrategy](/nearby/messages/ios/reference/interface_g_n_s_beacon_strategy)\\*) beaconStrategy | | readwritenonatomicassign |\n\nThe strategy to use for beacon scanning. \n\n|-------------------------------------------------------------------------------------------------|------------------------|\n| |---------------------------------------------| | - (GNSOperationStatusHandler) statusHandler | | readwritenonatomiccopy |\n\nA handler for subscription status.\n\nIt can be used for tracking the status of a newly created subscription. \n\n|---------------------------------------------------------------------------------------------------------------------------|------------------------|\n| |----------------------------------------------------------| | - (GNSPermissionRequestHandler) permissionRequestHandler | | readwritenonatomiccopy |\n\nA handler for requesting user permission to use Nearby.\n\nThis handler overrides the default dialog used by Nearby; if you supply this handler, Nearby will not show its permission dialog.\n\nIn your request handler, you should request the user's permission to perform the task that requires the use of Nearby, explaining why it's being used. When the user has given or denied consent, you must call the block that's passed into your request handler. If you pass `YES` into the block, it means the user has consented to allow Nearby to function. If you pass `NO`, it means the user has not consented; your publications and subscriptions will not work until consent has been given.\n\nThe handler can also be used as a method of \"preflighting\" for the iOS permission dialogs. You can use it to explain why the user is expected to consent to the iOS permissions before your app can perform its Nearby related functions."]]