Open History to see the last commit
1import type { RelayDeviceRegistrationRequest } from "@t3tools/contracts/relay";
2
3import type { Preferences } from "../../lib/storage";
4
5export function makeRelayDeviceRegistrationRequest(input: {
6 readonly deviceId: string;
7 readonly label: string;
8 readonly iosMajorVersion: number;
9 readonly appVersion?: string;
10 readonly pushToken?: string;
11 readonly pushToStartToken?: string;
12 readonly notificationsEnabled: boolean;
13 readonly preferences: Preferences;
14}): RelayDeviceRegistrationRequest {
15 const liveActivitiesEnabled = input.preferences.liveActivitiesEnabled !== false;
16 return {
17 deviceId: input.deviceId,
18 label: input.label,
19 platform: "ios",
20 iosMajorVersion: input.iosMajorVersion,
21 appVersion: input.appVersion,
22 ...(input.pushToken ? { pushToken: input.pushToken } : {}),
23 ...(input.pushToStartToken ? { pushToStartToken: input.pushToStartToken } : {}),
24 preferences: {
25 liveActivitiesEnabled,
26 notificationsEnabled: input.notificationsEnabled,
27 notifyOnApproval: true,
28 notifyOnInput: true,
29 notifyOnCompletion: true,
30 notifyOnFailure: true,
31 },
32 };
33}