Класс GNSMessage
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
Сообщение — это опубликованный объект, который доставляется между соседними устройствами.
Сообщения доставляются только между приложениями, имеющими один и тот же идентификатор консоли разработчика Apiary. См. https://code.google.com/apis/console/ .
У сообщения также есть тип, который используется для сопоставления опубликованного сообщения с подписками.
- Смотрите также
- GNSMessageManager для получения дополнительной информации о публикациях и подписках.
Наследует NSObject.
|
((unavailable("Use
+messageWithContent.") | - __attribute__ |
|
+ (instancetype) messageWithContent: |
|
(NSData *) |
content |
|
- (NSString*) messageNamespace |
|
read nonatomic copy |
Пространство имен типа сообщения.
Пустая строка является пространством имен по умолчанию и является частной для каждого приложения (или приложений, совместно использующих проект консоли разработчика Google). Обратите внимание, что в настоящее время только вложения маяков будут иметь пространство имен, отличное от стандартного.
Тип сообщения.
Не может быть длиннее символов Юникода kGNSMessageMaximumLength. Попытка использовать более длинный тип приведет к тому, что библиотека подтвердит, включены ли утверждения, и не опубликует сообщение, если утверждения отключены.
Содержание сообщения.
Формат данных зависит от приложения и должен быть согласован всеми издателями и подписчиками данных. Не может быть длиннее kGNSMessageMaximumContentSize. Попытка использовать объект большего размера приведет к тому, что библиотека подтвердит, включены ли утверждения, и не опубликует сообщение, если утверждения отключены.
Если не указано иное, контент на этой странице предоставляется по лицензии Creative Commons "С указанием авторства 4.0", а примеры кода – по лицензии Apache 2.0. Подробнее об этом написано в правилах сайта. Java – это зарегистрированный товарный знак корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-08-13 UTC.
[null,null,["Последнее обновление: 2025-08-13 UTC."],[[["\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."]]