Skip to content

Preferences

Your team gives the app topics on Settings › your app › Messaging rules › Topics, such as “Offers” and “New arrivals”, each going by some of email, push, in the app and chat. A person hears about a topic by a channel only when they are subscribed to it: their own choice, or the topic’s default when they never chose. Consent and topics explains the whole model.

PurrCRM‘s emails link to a preference page on the web. In your app, you draw the preferences screen; the SDK reads the choices and keeps each change. The page is behind no part: anyone signed in may open it, and navigate sends it to /messages/preferences (Initialise).

crm.preferencesEditor() backs a screen that changes one switch at a time:

src/preferences.ts
const editor = crm.preferencesEditor({ wording: "2026-10" });
const stop = editor.state.subscribe((s) => {
if (s.preferences === null) return s.loading ? drawSpinner() : drawFailure(s.message);
for (const topic of s.preferences.topics) {
// topic.name and topic.description in the user's language, where your team translated them
for (const c of topic.channels) {
drawSwitch(topic, c.channel, c.subscribed, (on) => editor.choose(topic.id, c.channel, on));
}
}
savedLine.textContent = s.saving > 0 ? "Saving…" : s.kept ? "Saved" : "";
if (s.saveMessage !== null) drawFailure(s.saveMessage);
});
await editor.load();
allOffButton.onclick = () => editor.turnAllOff(); // "Unsubscribe from all offers and news"
// When the screen goes:
stop();
editor.close();

Each change shows at once and goes to PurrCRM, one after another, in the order made. A change PurrCRM refuses is put back, the preferences are read again, and saveMessage says why. kept says every change has been kept, for a “Saved” line. A channel is email, push, in_app or chat; one your code does not know reads as "unknown".

wording is your own id for the version of the words you show beside the switches, such as "2026-10", up to 100 characters. PurrCRM records it with each change, so it can say later what the person agreed to. Change it whenever you change the words. It is optional for preferencesEditor and setPreferences alike: left out, no wording is sent and the change is recorded without one. (crm_sdk/preferences-1 is the id the Flutter SDK’s own preferences screen sends for its words; your screen’s words are yours, so give your own.)

const prefs = await crm.preferences(); // null when PurrCRM could not be reached
if (prefs !== null) {
await crm.setPreferences(
[{ topicId: prefs.topics[0]!.id, channel: "email", subscribed: false }],
{ wording: "2026-10" },
);
}
await crm.setPreferences([], { allOff: true, wording: "2026-10" }); // every topic off

Both answer the preferences as kept, or null when PurrCRM could not be reached. prefs.allOff says the person turned all offers and news off.

crm.offersByPush() and crm.setOffersByPush(on) are the push channel’s own switch, above every topic (Push). A marketing push reaches only people who agreed to it.

The person’s choice about product analytics is not a topic: say it in their session with productEventsOff (Events).