Files
hipmi-mobile/app/(application)/(user)/test-notifications.tsx
bagasbanuna a01a9bd93f Filter console dan clean code
Add:
- service/api-device-token.ts

Fix:
- app/(application)/(user)/home.tsx
- app/(application)/(user)/test-notifications.tsx
- app/_layout.tsx
- components/_ShareComponent/NotificationInitializer.tsx
- context/AuthContext.tsx
- hooks/use-foreground-notifications.ts
- screens/Home/HeaderBell.tsx
- service/api-notifications.ts

### No Issue
2025-12-17 17:46:28 +08:00

68 lines
1.6 KiB
TypeScript

import {
ButtonCustom,
NewWrapper,
StackCustom,
TextInputCustom,
} from "@/components";
import { useAuth } from "@/hooks/use-auth";
import { apiGetAllTokenDevice } from "@/service/api-device-token";
import {
apiNotificationsSend,
} from "@/service/api-notifications";
import { useEffect, useState } from "react";
export default function TestNotification() {
const { user } = useAuth();
const [data, setData] = useState("");
useEffect(() => {
// fecthData();
}, []);
const fecthData = async () => {
const response = await apiGetAllTokenDevice();
console.log(
"[RES GET ALL TOKEN DEVICE]",
JSON.stringify(response.data, null, 2)
);
};
const handleSubmit = async () => {
console.log("[Data Dikirim]", data);
const response = await apiNotificationsSend({
data: {
fcmToken:
"cVmHm-3P4E-1vjt6AA9kSF:APA91bHTkHjGTLxrFsb6Le6bZmzboZhwMGYXU4p0FP9yEeXixLDXNKS4F5vLuZV3sRgSnjjQsPpLOgstVLHJB8VJTObctKLdN-CxAp4dnP7Jbc_mH53jWvs",
title: "Test dari Backend (App Router)!",
body: data,
userLoginId: user?.id || "",
},
});
console.log("[RES SEND NOTIF]", JSON.stringify(response.data, null, 2));
};
return (
<>
<NewWrapper>
<StackCustom>
<TextInputCustom
required
label="Nama"
placeholder="Masukkan nama"
value={data}
onChangeText={(text) => setData(text)}
/>
<ButtonCustom
onPress={() => {
handleSubmit();
}}
>
Kirim
</ButtonCustom>
</StackCustom>
</NewWrapper>
</>
);
}