# GNSMessage Class

[Instance Methods](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#pub-methods) \| [Class Methods](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#pub-static-methods) \| [Properties](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#properties) GNSMessage Class Reference

## Overview

A message is a published object that is delivered between nearby devices.

Messages are delivered only between apps sharing the same Apiary Dev Console ID. See <https://code.google.com/apis/console/>

A message also has a type, which is used to match a published message with subscriptions.

See also
:   [GNSMessageManager](https://developers.google.com/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.

Inherits NSObject.

|---|---|
| ## Instance Method Summary ||
| ((unavailable("Use +messageWithContent.") | - **__attribute__** |
|   ||

|---|---|
| ## Class Method Summary ||
| (instancetype) | + [messageWithContent:](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#a11c95fc8aa716759a95b46ac2d9658b5) |
|   | Message with the default type. [More...](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#a11c95fc8aa716759a95b46ac2d9658b5) |
|   ||
| (instancetype) | + [messageWithContent:type:](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#a86840561e1ebbcb98ad209adc110fb74) |
|   | Message with the specified type. [More...](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#a86840561e1ebbcb98ad209adc110fb74) |
|   ||

|---|---|
| ## Property Summary ||
| NSString \* | [messageNamespace](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#aad0830d118becf213310c83b279bf0a6) |
|   | The namespace of the message type. [More...](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#aad0830d118becf213310c83b279bf0a6) |
|   ||
| NSString \* | [type](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#a20d9593b44edfbfa78e4d4416d8a2a1c) |
|   | The type of the message. [More...](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#a20d9593b44edfbfa78e4d4416d8a2a1c) |
|   ||
| NSData \* | [content](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#abd1454b18947ac01b56ac926ff9e6626) |
|   | The content of the message. [More...](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#abd1454b18947ac01b56ac926ff9e6626) |
|   ||

## Method Detail

|---|---|---|---|---|
| + (instancetype) messageWithContent: |   | (NSData \*) | *content* |   |

Message with the default type.

See also
:   [GNSMessage.content](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#abd1454b18947ac01b56ac926ff9e6626 "The content of the message. ") for more information about the [content](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#abd1454b18947ac01b56ac926ff9e6626 "The content of the message. ").

|---|---|---|---|
| + (instancetype) [messageWithContent:](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#a11c95fc8aa716759a95b46ac2d9658b5) |   | (NSData \*) | *content* |
| type: |   | (NSString \*) | *type* |
|   |   |   |   |

Message with the specified type.

See also
:   [GNSMessage.content](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#abd1454b18947ac01b56ac926ff9e6626 "The content of the message. ") for more information about the [content](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#abd1454b18947ac01b56ac926ff9e6626 "The content of the message. ").
:
    [GNSMessage.type](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#a20d9593b44edfbfa78e4d4416d8a2a1c "The type of the message. ") for more information about the [type](https://developers.google.com/nearby/messages/ios/reference/interface_g_n_s_message#a20d9593b44edfbfa78e4d4416d8a2a1c "The type of the message. ").

## Property Detail

|---|---|
| |---| | - (NSString\*) messageNamespace | | readnonatomiccopy |

The namespace of the message type.

The 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.

|---|---|
| |---| | - (NSString\*) type | | readnonatomiccopy |

The type of the message.

Cannot 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.

|---|---|
| |---| | - (NSData\*) content | | readnonatomiccopy |

The content of the message.

The 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.