Table of Contents

Message Access (MAP)

MAP — Message Access Profile. Read a phone's SMS/MMS history, send messages, delete them, mark them read, and receive new messages as they arrive.

MAP runs over OBEX, so it depends on obexd — which the extension starts and stops alongside bluetoothd.

Table of Contents

Capabilities

Client

Connecting

Loading History

Receiving New Messages

Sending

Delete and Mark Read

Gotchas

Desktop Stack Behavior

Capabilities

  • Load message history from the phone's folders
  • Receive pushed notifications for newly arrived messages
  • Send a text message
  • Delete a message
  • Mark a message read
  • Refresh the inbox on demand

The Classic demo's Message Access panel with history synced, showing dated messages with sender and unread markers, and controls for sync, mark-read, delete, and reply

Client

using Ahsoka.Core;
using Ahsoka.Services.Bluetooth.Profiles.MessageAccess;
using Ahsoka.Services.Bluetooth.Proto;

var messageAccessClient = new MessageAccessServiceClient();

Dispatcher.Default.RegisterCallback<AhsokaClientBase<MessageAccessProfileMessageTypes.Ids>.AhsokaNotificationArgs>(
    OnMessageAccessNotification,
    messageAccessClient);

messageAccessClient.Start();

The adapter must declare MessageAccessProfileService in SupportedProfileServiceTypes.

Method Purpose
RequestConnectProfile(BluetoothDevicePairedInfo) Connect the profile (inherited)
RequestDisconnectProfile(BluetoothDevicePairedInfo) Disconnect (inherited)
LoadHistory(ushort? maxPerFolder = 50) Fetch history; 0 means load everything
SendTextMessage(TextMessage) Send
DeleteTextMessage(TextMessage) Delete
MarkAsRead(TextMessage) Mark read
RefreshInbox() Re-read the inbox
Notification Payload Meaning
ProfileConnectionStateChanged ProfileConnectionInfo Connection state
MapMessageReceived TextMessage A message — from history or newly pushed
MapLoadHistoryComplete — History load finished
MapSendMessageComplete — Send finished

Connecting

if (device.SupportedProfiles.HasFlag(BluetoothProfilesFlags.Map))
    messageAccessClient.RequestConnectProfile(device);

Wait for StateConnected before calling LoadHistory — an OBEX session has to be established first.

Loading History

messageAccessClient.LoadHistory(50);   // 50 per folder
messageAccessClient.LoadHistory(0);    // everything

Messages arrive one at a time as MapMessageReceived, then MapLoadHistoryComplete marks the end:

switch (e.TransportId)
{
    case MessageAccessProfileMessageTypes.Ids.MapMessageReceived
        when e.NotificationObject is TextMessage message:
        AddOrUpdateMessage(message);
        break;

    case MessageAccessProfileMessageTypes.Ids.MapLoadHistoryComplete:
        FinishLoading();
        break;
}

TextMessage:

Property Meaning
Id The phone's message handle — the identity to pass back to delete or mark-read
Content Message body
Number Sender or recipient number
Name Sender or recipient name, where the phone supplies one
Timestamp Unix timestamp
Folder Which folder it came from — inbox, sent, and so on
Read Read status

Keep the whole TextMessage you received. DeleteTextMessage and MarkAsRead need the Id, and reconstructing one by hand will not work.

LoadHistory on a phone with a long history is slow. Start with a modest maxPerFolder, and if you offer "load all", show progress — messages arriving one notification at a time is your progress signal.

An empty result means the folder is genuinely empty. There is no push-only device: if history comes back with nothing, there is nothing there.

Receiving New Messages

MapMessageReceived is also how newly arrived messages reach you — the same notification and payload type as history. It fires when the phone pushes a new message over MAP's notification channel.

You cannot tell "history" from "just arrived" by the message alone. If that distinction matters, track whether a load is in progress: messages between LoadHistory and MapLoadHistoryComplete are history, and anything after is a live arrival.

Registration for these push notifications is handled inside obexd once the OBEX session is established. There is nothing to call.

Sending

messageAccessClient.SendTextMessage(new TextMessage
{
    Number = "+15551234567",
    Content = "On my way"
});

MapSendMessageComplete reports that the send finished. Whether the phone actually transmitted it is up to the phone and its network.

Delete and Mark Read

Both take a TextMessage you previously received:

messageAccessClient.MarkAsRead(message);
messageAccessClient.DeleteTextMessage(message);

Neither reports a dedicated completion notification. Where a phone reflects the change, you will see it on the next RefreshInbox() or LoadHistory.

Gotchas

Phone behavior differs substantially between iOS and Android, more than for any other profile here. Test against both. Symptoms and causes are in Troubleshooting.

Never build a multi-segment folder path. Folder navigation is per segment. Passing something like telecom/msg/inbox as a single value fails on Android and silently returns zero messages on iOS. The extension handles navigation internally, so this only matters if you are working below the client API.

Read status and deletion may not round-trip. Some phones accept a mark-read or delete and do not reflect it back. Do not assume your local view and the phone's agree; re-read to confirm.

MAP needs obexd. It starts with bluetoothd automatically, but if OBEX-based profiles are the only ones failing, that unit is where to look.

Album art and MAP both use OBEX. On a device paired to more than one adapter, an OBEX session that does not pin its source adapter can trigger a pairing prompt on the wrong one. The extension pins it; the symptom is documented in Troubleshooting because it is easy to mistake for a pairing bug.

Desktop Stack Behavior

The desktop MessageAccess stub simulates a connected phone with a message store, so history loading, the message list UI, send, delete, and mark-read can all be built and debugged on Windows.

What it does not reproduce is the per-device inconsistency that dominates real MAP work — the iOS/Android differences, phones that ignore mark-read, and slow history loads. This profile is hardware-validated, but validate your own UI against both phone platforms before shipping.

The Classic demo's Message Access panel exercises the full API: history sync, the message list, mark-read, delete, and reply.