Start Here
This page will have the basics that you'll want to start with when creating your chat app. Use the menu to jump to where you need to go.
Start Matrix
Password Login
const login = async () => {
const result = await rnm.loginWithPassword(
username,
password,
homeserver,
true, // enable crypto? default false
);
if (result.error) {
setLoading(false);
console.log('Error logging in: ', result);
setError(result.message);
}
};Token Login
rnm.createClient(homeserver, accessToken, mxid, deviceId?);
rnm.start(); // pass "true" to enable cryptoGet a list of rooms
Using Core
This is what's happening in /ui in the RoomList component behind the scenes. Render rooms and invites however you'd like. inviteList is a list of rooms you are not a part of yet, but have been invited to.
updateLists is a function which refreshes the lists, usually in the event of an invite rejection / acceptance.
Using UI
The RoomList component will show a simple inbox. However, you can override what it looks like by using the prop renderListItem. Read more at RoomList.
Join room
Be sure to update the lists after joinRoom resolves.
Reject room invite
Be sure to update the lists after leaveRoom resolves.
Get avatar for room
View the Room method getAvatarUrl
Get messages in a room
Using Core
timeline is the actual list of messages.
updates is an array of messages that are deleted, edited, etc and therefore should be re-rendered in the view. Using this, you can memoize your MessageItem, reducing the number of useless re-renders on your screen.
To see an implementation of this including fetching previous messages, handling touches on the screen, rendering a typing indicator, etc, you can see that in the example app.
Using UI
View the docs on MessageList to see what you can do for handling touches (onPress, onLongPress).
To see this in a code example, view this piece of the example app.
Send message to a room
Send message
Text
For automatic conversion of markdown to html:
rnm.sendTextMessage(roomId, content) // content is your markdown string
For basic sending (no alterations made):
rnm.getClient().sendTextMessage(roomId, content)
Image or Video
rnm.sendMediaMessage(roomId, content, type)
In this case, content is something that is received directly from something like ImagePicker.
type is either m.image or m.video
Send reply
relatedMessage is the MatrixEvent which is being replied to.
Edit message
Delete a message
Create a room
Not available yet.
Last updated