Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

androidNotifications.ts

35 lines975 Bytes

1import Constants from "expo-constants";
2import { requireOptionalNativeModule } from "expo";
3import { Platform } from "react-native";
4​
5interface AndroidAgentNotifications {
6 configure(deviceId: string, userId: string, scheme: string, ongoingEnabled: boolean): void;
7 clear(): void;
8}
9​
10const native =
11 Platform.OS === "android"
12 ? requireOptionalNativeModule<AndroidAgentNotifications>("T3AgentNotifications")
13 : null;
14​
15export function supportsAndroidAgentNotifications(): boolean {
16 return typeof native?.configure === "function" && typeof native?.clear === "function";
18​
19export function configureAndroidAgentNotifications(
20 deviceId: string,
21 userId: string,
22 ongoingEnabled: boolean,
23): void {
24 const scheme = Constants.expoConfig?.scheme;
25 native?.configure?.(
26 deviceId,
27 userId,
28 (Array.isArray(scheme) ? scheme[0] : scheme) ?? "t3code",
29 ongoingEnabled,
30 );
32​
33export function clearAndroidAgentNotifications(): void {
34 native?.clear?.();