کلاس GNSMessage
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
پیام یک شی منتشر شده است که بین دستگاه های نزدیک تحویل داده می شود.
پیامها فقط بین برنامههایی که همان شناسه کنسول Apiary Dev Console را به اشتراک میگذارند، ارسال میشود. به https://code.google.com/apis/console/ مراجعه کنید
یک پیام همچنین دارای یک نوع است که برای تطبیق پیام منتشر شده با اشتراک ها استفاده می شود.
- همچنین ببینید
- GNSMessageManager برای اطلاعات بیشتر درباره انتشارات و اشتراکها.
NSObject را به ارث می برد.
|
((unavailable("Use
+messageWithContent.") | - __attribute__ |
|
+ (instancetype) messageWithContent: |
|
(NSData *) |
content |
|
- (NSString*) messageNamespace |
|
read nonatomic copy |
فضای نام نوع پیام
رشته خالی فضای نام پیشفرض است و برای هر برنامه (یا برنامههایی که پروژه کنسول برنامهنویس Google را به اشتراک میگذارند) خصوصی است. توجه داشته باشید که در حال حاضر، فقط پیوست های beacon فضای نامی غیر از پیش فرض خواهند داشت.
نوع پیام.
نمی تواند بیشتر از نویسه های یونیکد kGNSMessageMaximumLength باشد. تلاش برای استفاده از نوع طولانیتر باعث میشود که کتابخانه در صورت فعال بودن ادعاها ادعا کند و در صورت غیرفعال شدن ادعاها، پیام را منتشر نکند.
محتوای پیام.
قالب داده ها برای برنامه خاص است و باید توسط همه ناشران و مشترکین داده ها توافق شود. نمی تواند بیشتر از kGNSMessageMaximumContentSize باشد. تلاش برای استفاده از یک شی بزرگتر از این باعث می شود که کتابخانه در صورت فعال بودن ادعاها ادعا کند و در صورت غیرفعال شدن ادعاها پیام را منتشر نکند.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-13 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-13 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe \u003ccode\u003eGNSMessage\u003c/code\u003e class facilitates communication between nearby devices by publishing and delivering messages between apps sharing the same Apiary Dev Console ID.\u003c/p\u003e\n"],["\u003cp\u003eMessages have a content and type, allowing applications to filter and process relevant messages; content is application-specific, while type enables matching with subscriptions.\u003c/p\u003e\n"],["\u003cp\u003eYou can create messages using class methods \u003ccode\u003emessageWithContent:\u003c/code\u003e for the default type, or \u003ccode\u003emessageWithContent:type:\u003c/code\u003e to specify a custom type.\u003c/p\u003e\n"],["\u003cp\u003eMessages are restricted in size: type cannot exceed \u003ccode\u003ekGNSMessageMaximumLength\u003c/code\u003e Unicode characters and content cannot be larger than \u003ccode\u003ekGNSMessageMaximumContentSize\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe message namespace, primarily used for beacon attachments, defaults to an empty string and is private to apps or apps sharing a Google Developer Console project.\u003c/p\u003e\n"]]],["The GNSMessage class manages messages delivered between nearby devices within the same app or apps sharing an ID. Messages have content, a type, and a namespace. Key actions include creating messages using class methods: `messageWithContent:` for the default type and `messageWithContent:type:` for a specified type. Properties include `messageNamespace`, `type`, and `content`, which hold the message's namespace, type, and data, respectively. Message size and type length have limits.\n"],null,["# GNSMessage Class\n\n[Instance Methods](#pub-methods) \\| [Class Methods](#pub-static-methods) \\| [Properties](#properties) \nGNSMessage Class Reference \n\nOverview\n--------\n\nA message is a published object that is delivered between nearby devices.\n\nMessages are delivered only between apps sharing the same Apiary Dev Console ID. See \u003chttps://code.google.com/apis/console/\u003e\n\nA message also has a type, which is used to match a published message with subscriptions.\n\nSee also\n: [GNSMessageManager](/nearby/messages/ios/reference/interface_g_n_s_message_manager \"The message manager lets you create publications and subscriptions. \") for more information about publications and subscriptions.\n\nInherits NSObject.\n\n|-------------------------------------------|---------------------|\n| Instance Method Summary ----------------------- ||\n| ((unavailable(\"Use +messageWithContent.\") | - **__attribute__** |\n| ||\n\n|----------------|------------------------------------------------------------------------------------------------------------------------|\n| Class Method Summary -------------------- ||\n| (instancetype) | + [messageWithContent:](/nearby/messages/ios/reference/interface_g_n_s_message#a11c95fc8aa716759a95b46ac2d9658b5) |\n| | Message with the default type. [More...](#a11c95fc8aa716759a95b46ac2d9658b5) |\n| ||\n| (instancetype) | + [messageWithContent:type:](/nearby/messages/ios/reference/interface_g_n_s_message#a86840561e1ebbcb98ad209adc110fb74) |\n| | Message with the specified type. [More...](#a86840561e1ebbcb98ad209adc110fb74) |\n| ||\n\n|-------------|--------------------------------------------------------------------------------------------------------------|\n| Property Summary ---------------- ||\n| NSString \\* | [messageNamespace](/nearby/messages/ios/reference/interface_g_n_s_message#aad0830d118becf213310c83b279bf0a6) |\n| | The namespace of the message type. [More...](#aad0830d118becf213310c83b279bf0a6) |\n| ||\n| NSString \\* | [type](/nearby/messages/ios/reference/interface_g_n_s_message#a20d9593b44edfbfa78e4d4416d8a2a1c) |\n| | The type of the message. [More...](#a20d9593b44edfbfa78e4d4416d8a2a1c) |\n| ||\n| NSData \\* | [content](/nearby/messages/ios/reference/interface_g_n_s_message#abd1454b18947ac01b56ac926ff9e6626) |\n| | The content of the message. [More...](#abd1454b18947ac01b56ac926ff9e6626) |\n| ||\n\nMethod Detail\n-------------\n\n|--------------------------------------|---|-------------|-----------|---|\n| + (instancetype) messageWithContent: | | (NSData \\*) | *content* | |\n\nMessage with the default type.\n\nSee also\n: [GNSMessage.content](/nearby/messages/ios/reference/interface_g_n_s_message#abd1454b18947ac01b56ac926ff9e6626 \"The content of the message. \") for more information about the [content](/nearby/messages/ios/reference/interface_g_n_s_message#abd1454b18947ac01b56ac926ff9e6626 \"The content of the message. \"). \n\n|----------------------------------------------------------------------------------------------------------------------------------|---|---------------|-----------|\n| + (instancetype) [messageWithContent:](/nearby/messages/ios/reference/interface_g_n_s_message#a11c95fc8aa716759a95b46ac2d9658b5) | | (NSData \\*) | *content* |\n| type: | | (NSString \\*) | *type* |\n| | | | |\n\nMessage with the specified type.\n\nSee also\n: [GNSMessage.content](/nearby/messages/ios/reference/interface_g_n_s_message#abd1454b18947ac01b56ac926ff9e6626 \"The content of the message. \") for more information about the [content](/nearby/messages/ios/reference/interface_g_n_s_message#abd1454b18947ac01b56ac926ff9e6626 \"The content of the message. \").\n:\n [GNSMessage.type](/nearby/messages/ios/reference/interface_g_n_s_message#a20d9593b44edfbfa78e4d4416d8a2a1c \"The type of the message. \") for more information about the [type](/nearby/messages/ios/reference/interface_g_n_s_message#a20d9593b44edfbfa78e4d4416d8a2a1c \"The type of the message. \").\n\nProperty Detail\n---------------\n\n|-------------------------------------------------------------------------|-------------------|\n| |---------------------------------| | - (NSString\\*) messageNamespace | | readnonatomiccopy |\n\nThe namespace of the message type.\n\nThe empty string is the default namespace, and is private to each app (or apps sharing a Google Developer Console project). Note that currently, only beacon attachments will have a namespace other than the default. \n\n|-------------------------------------------------|-------------------|\n| |---------------------| | - (NSString\\*) type | | readnonatomiccopy |\n\nThe type of the message.\n\nCannot be longer than kGNSMessageMaximumLength Unicode characters. Attempting to use a longer type will cause the library to assert if assertions are enabled and not publish the message if assertions are disabled. \n\n|---------------------------------------------------|-------------------|\n| |----------------------| | - (NSData\\*) content | | readnonatomiccopy |\n\nThe content of the message.\n\nThe format of the data is application-specific, and must be agreed upon by all publishers and subscribers of the data. Cannot be longer than kGNSMessageMaximumContentSize. Attempting to use an object larger than this will cause the library to assert if assertions are enabled and not publish the message if assertions are disabled."]]