Points
Permissions: points.read (read), points.earn (award).
import { earnPoints } from '@i-catholic/mini-app-sdk'
const total = await sdk.getPoints() // number
const { totalPoints, queuedOffline } = await earnPoints({
action: 'mini-app-quiz-complete',
metadata: { score: 9, level: 'hard' },
})
if (queuedOffline) {
// offline: the app queued it and submits it on reconnect
}
actionmust be one ofEARN_POINTS_ACTIONS:'mini-app-complete','mini-app-daily-visit','mini-app-share','mini-app-quiz-complete'. Anything else rejects withINVALID_PARAMS.metadatatakes primitives only (string,number,boolean). The app keeps the first 20 keys, truncates strings to 512 characters, and drops other values (EARN_POINTS_METADATA_LIMITS).- A server-side refusal (already completed today, rate limited, …) rejects with
ACTION_FAILED. The reason is ine.message(e.g.'RATE_LIMIT_EXCEEDED'). - Use the
earnPoints()helper rather thansdk.earnPoints(). The raw method returns the server body unmapped (RawEarnPointsResult). - The new total also arrives as a
pointsUpdateevent (usePoints()follows it).