updateChat
Update chat properties such as display name.
await sdk.chats.updateChat(guid, options): Promise<ChatResponse>
Parameters
Unique identifier of the chat to update
Properties to updateNew display name for the chat
Returns
Example
import { SDK } from '@photon-ai/advanced-imessage-kit';
const sdk = SDK({ serverUrl: 'http://localhost:1234' });
// Update group chat name
const updatedChat = await sdk.chats.updateChat('iMessage;+;chat123456', {
displayName: 'Weekend Trip Planning'
});
console.log(`Chat renamed to: ${updatedChat.displayName}`);
addParticipant
Add a participant to a group chat.
await sdk.chats.addParticipant(chatGuid, address): Promise<ChatResponse>
Parameters
Unique identifier of the chat
Phone number or email address of the participant to add
Returns
Updated chat object with new participant
Example
import { SDK } from '@photon-ai/advanced-imessage-kit';
const sdk = SDK({ serverUrl: 'http://localhost:1234' });
const chatGuid = 'iMessage;+;chat123456';
// Add participant by phone number
const updatedChat = await sdk.chats.addParticipant(
chatGuid,
'+1234567890'
);
console.log(`Participant added. Chat now has ${updatedChat.participants?.length} members`);
// Add participant by email
await sdk.chats.addParticipant(chatGuid, 'newperson@icloud.com');
removeParticipant
Remove a participant from a group chat.
await sdk.chats.removeParticipant(chatGuid, address): Promise<ChatResponse>
Parameters
Unique identifier of the chat
Phone number or email address of the participant to remove
Returns
Updated chat object without the removed participant
Example
import { SDK } from '@photon-ai/advanced-imessage-kit';
const sdk = SDK({ serverUrl: 'http://localhost:1234' });
const chatGuid = 'iMessage;+;chat123456';
// Remove participant
const updatedChat = await sdk.chats.removeParticipant(
chatGuid,
'+1234567890'
);
console.log(`Participant removed. ${updatedChat.participants?.length} members remaining`);
leaveChat
Leave a group chat.
await sdk.chats.leaveChat(guid): Promise<void>
Parameters
Unique identifier of the chat to leave
Returns
Returns a Promise that resolves when the operation completes.
Example
import { SDK } from '@photon-ai/advanced-imessage-kit';
const sdk = SDK({ serverUrl: 'http://localhost:1234' });
// Leave a group chat
await sdk.chats.leaveChat('iMessage;+;chat123456');
console.log('Successfully left the chat');
setGroupIcon
Set a custom icon/image for a group chat.
await sdk.chats.setGroupIcon(chatGuid, filePath): Promise<void>
Parameters
Unique identifier of the chat
Path to the image file to use as the group icon
Returns
Returns a Promise that resolves when the operation completes.
Example
import { SDK } from '@photon-ai/advanced-imessage-kit';
import path from 'path';
const sdk = SDK({ serverUrl: 'http://localhost:1234' });
const chatGuid = 'iMessage;+;chat123456';
// Set group icon from local file
const iconPath = path.join(__dirname, 'images', 'group-icon.png');
await sdk.chats.setGroupIcon(chatGuid, iconPath);
console.log('Group icon updated successfully');
removeGroupIcon
Remove the custom icon from a group chat.
await sdk.chats.removeGroupIcon(chatGuid): Promise<void>
Parameters
Unique identifier of the chat
Returns
Returns a Promise that resolves when the operation completes.
Example
import { SDK } from '@photon-ai/advanced-imessage-kit';
const sdk = SDK({ serverUrl: 'http://localhost:1234' });
// Remove group icon
await sdk.chats.removeGroupIcon('iMessage;+;chat123456');
console.log('Group icon removed');
deleteChat
Delete a chat from your message history.
Method Signature
await sdk.chats.deleteChat(guid: string): Promise<void>
Parameters
Unique identifier of the chat to delete
Example
await sdk.chats.deleteChat("iMessage;-;+1234567890");
console.log("Chat deleted from history");
This only removes the chat from your local message database. It does not affect the chat for other participants.
markChatRead
Mark a chat as read.
Method Signature
await sdk.chats.markChatRead(guid: string): Promise<void>
Parameters
Unique identifier of the chat to mark as read
Example
await sdk.chats.markChatRead("iMessage;-;+1234567890");
markChatUnread
Mark a chat as unread.
Method Signature
await sdk.chats.markChatUnread(guid: string): Promise<void>
Parameters
Unique identifier of the chat to mark as unread
Example
await sdk.chats.markChatUnread("iMessage;-;+1234567890");
getGroupIcon
Get the group icon image for a group chat.
Method Signature
await sdk.chats.getGroupIcon(guid: string): Promise<Buffer>
Parameters
Unique identifier of the group chat
Returns
Returns a Buffer containing the group icon image data.
Example
import fs from 'fs';
const iconBuffer = await sdk.chats.getGroupIcon("iMessage;+;chat123456");
// Save to file
fs.writeFileSync('group-icon.png', iconBuffer);
// Or convert to base64
const base64Icon = iconBuffer.toString('base64');
getChatCount
Get the total count of chats.
Method Signature
await sdk.chats.getChatCount(): Promise<number>
Returns
Returns the total number of chats.
Example
const totalChats = await sdk.chats.getChatCount();
console.log(`Total chats: ${totalChats}`);