GNSअनुमति श्रेणी
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
इस क्लास की मदद से, आपको मौजूदा डिवाइस पर ऐप्लिकेशन के लिए, 'आस-पास' सुविधा की अनुमति की स्थिति को मैनेज करने की सुविधा मिलती है.
पब्लिकेशन और सदस्यताओं के काम करने से पहले, उपयोगकर्ता को अनुमति देनी होगी. जब ऐप्लिकेशन पहली बार पब्लिकेशन या सदस्यता बनाता है, तो आस-पास की सुविधा के लिए अनुमति वाला डायलॉग अपने-आप दिखता है. इससे, लोगों को ऑप्ट-इन करने का मौका मिलता है. अगर उपयोगकर्ता ऐसा नहीं करता है, तो हर बार पब्लिकेशन या सदस्यता बनाने पर एक सूचना दिखेगी. इससे, उन्हें ऑप्ट इन करने का एक और मौका मिलेगा.
हमारा सुझाव है कि आपका ऐप्लिकेशन, उपयोगकर्ता के पास कोई ऐसा तरीका उपलब्ध कराएं जिससे वह अनुमति को चालू या बंद कर सके. उदाहरण के लिए, सेटिंग पेज में टॉगल स्विच का इस्तेमाल करके. जब उपयोगकर्ता इसे टॉगल करता है, तब अनुमति की स्थिति को टॉगल करने के लिए, ऐप्लिकेशन को नीचे दिए गए isGranted
और setGranted
तरीकों को कॉल करना चाहिए.
अनुमति की स्थिति ट्रैक करने के लिए, GNSPermission
ऑब्जेक्ट बनाएं और बदले गए हैंडलर में पास करें. जब भी अनुमति की स्थिति बदली जाएगी, तब हैंडलर को कॉल किया जाएगा. इससे आपके ऐप्लिकेशन के यूज़र इंटरफ़ेस (यूआई) को मौजूदा स्थिति के साथ सिंक रखा जा सकेगा.
NSObject को इनहेरिट करता है.
|
(BOOL) | + isGranted |
| इस डिवाइस पर मौजूद ऐप्लिकेशन के लिए, फ़िलहाल आस-पास की सुविधा इस्तेमाल करने की अनुमति दी गई है या नहीं. ज़्यादा...
|
|
(void) | + setGranted: |
| 'आस-पास' सुविधा की अनुमति की स्थिति बदलता है. ज़्यादा...
|
|
- (instancetype) initWithChangedHandler: |
|
(GNSPermissionHandler) |
changedHandler |
|
अनुमति ऑब्जेक्ट को एक हैंडलर के साथ शुरू करता है. इसे तब कॉल किया जाता है, जब अनुमति की स्थिति बदलती है.
हैंडलर की मदद से ऐप्लिकेशन, अपने यूज़र इंटरफ़ेस (यूआई) को अनुमति की स्थिति के साथ सिंक रखता है. हैंडलर को तब तक कॉल नहीं किया जाता, जब तक कि उपयोगकर्ता अनुमति को स्वीकार या अस्वीकार नहीं करता.
- Parameters
-
handler | The permission granted handler |
इस डिवाइस पर मौजूद ऐप्लिकेशन के लिए, फ़िलहाल आस-पास की सुविधा इस्तेमाल करने की अनुमति दी गई है या नहीं.
हां का मतलब है कि उपयोगकर्ता ने आस-पास शेयर करने की अनुमति दी है और नहीं का मतलब है कि उपयोगकर्ता ने अनुमति नहीं दी है. अगर अनुमति नहीं दी जाती है, तो पब्लिकेशन और सदस्यताएं काम नहीं करेंगी.
+ (void) setGranted: |
|
(BOOL) |
granted |
|
'आस-पास' सुविधा की अनुमति की स्थिति बदलता है.
इसे सिर्फ़ तब ही कॉल किया जाना चाहिए, जब उपयोगकर्ता अनुमति की स्थिति बदलने की कार्रवाई करे.
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-08-13 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-08-13 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eThe \u003ccode\u003eGNSPermission\u003c/code\u003e class manages the Nearby permission state for your app, enabling features like publications and subscriptions.\u003c/p\u003e\n"],["\u003cp\u003eUsers must grant Nearby permission for these features to function; the system automatically requests this permission when needed.\u003c/p\u003e\n"],["\u003cp\u003eYou can track and react to permission state changes using a \u003ccode\u003eGNSPermission\u003c/code\u003e object with a change handler.\u003c/p\u003e\n"],["\u003cp\u003eProvide a UI element, like a toggle switch, allowing users to control the Nearby permission and update the state using \u003ccode\u003eisGranted\u003c/code\u003e and \u003ccode\u003esetGranted\u003c/code\u003e methods.\u003c/p\u003e\n"],["\u003cp\u003eThe initial permission request is automatic, but subsequent requests depend on the user's previous choice and your app's UI for toggling the permission.\u003c/p\u003e\n"]]],[],null,["# GNSPermission Class\n\n[Instance Methods](#pub-methods) \\| [Class Methods](#pub-static-methods) \nGNSPermission Class Reference \n\nOverview\n--------\n\nThis class lets you manage the Nearby permission state for the app on the current device.\n\nThe user must grant permission before publications and subscriptions will work. The first time the application creates a publication or subscription, the Nearby permission dialog is automatically displayed, giving the user the opportunity to opt in. If the user denies, an alert will be displayed each time a publication or subscription is subsequently created, giving them another chance to opt in.\n\nIt is recommended that your app provide the user a method for switching the permission on or off; for instance, by using a toggle switch in a settings page. When the user toggles it, the app should call the `isGranted` and `setGranted` methods below to toggle the permission state.\n\nTo track the permission state, create a [GNSPermission](/nearby/messages/ios/reference/interface_g_n_s_permission \"This class lets you manage the Nearby permission state for the app on the current device...\") object and pass in a changed handler. The handler will be called whenever the permission state is changed, allowing your app's UI to be kept in sync with the current state.\n\nInherits NSObject.\n\n|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Instance Method Summary ----------------------- ||\n| (instancetype) | - [initWithChangedHandler:](/nearby/messages/ios/reference/interface_g_n_s_permission#a28317128a0274fd2f24c8e21456f2276) |\n| | Initializes the permission object with a handler that is called whenever the permission state changes. [More...](#a28317128a0274fd2f24c8e21456f2276) |\n| ||\n\n|--------|--------------------------------------------------------------------------------------------------------------------------|\n| Class Method Summary -------------------- ||\n| (BOOL) | + [isGranted](/nearby/messages/ios/reference/interface_g_n_s_permission#aef0ec5cb0489597c5e90a7af81b4b574) |\n| | Whether Nearby permission is currently granted for the app on this device. [More...](#aef0ec5cb0489597c5e90a7af81b4b574) |\n| ||\n| (void) | + [setGranted:](/nearby/messages/ios/reference/interface_g_n_s_permission#a115c4964d2f1b5317bf888cb40b6e0bf) |\n| | Changes the Nearby permission state. [More...](#a115c4964d2f1b5317bf888cb40b6e0bf) |\n| ||\n\nMethod Detail\n-------------\n\n|------------------------------------------|---|------------------------|------------------|---|\n| - (instancetype) initWithChangedHandler: | | (GNSPermissionHandler) | *changedHandler* | |\n\nInitializes the permission object with a handler that is called whenever the permission state changes.\n\nThe handler lets the app keep its UI in sync with the permission state. The handler is not called until the user has approved or denied permission.\n\nParameters\n:\n\n |---------|--------------------------------|\n | handler | The permission granted handler |\n\n\n|--------------------|---|---|---|\n| + (BOOL) isGranted | | | |\n\nWhether Nearby permission is currently granted for the app on this device.\n\nYES means the user has granted Nearby permission, and NO means the user has denied permission. If permission has not been granted, publications and subscriptions will not work. \n\n|----------------------|---|--------|-----------|---|\n| + (void) setGranted: | | (BOOL) | *granted* | |\n\nChanges the Nearby permission state.\n\nThis should be called only in response to the user action of changing the permission state."]]