Files
hipmi-mobile/service/api-notifications.ts
bagasbanuna 05c1cac10f Penerapan ke database
Fix:
- android/app/src/main/AndroidManifest.xml
- app/(application)/(user)/home.tsx
- components/_ShareComponent/NotificationInitializer.tsx
- ios/HIPMIBadungConnect.xcodeproj/project.pbxproj
- ios/HIPMIBadungConnect/Info.plist
- service/api-notifications.ts

### No Issue
2025-12-16 17:47:50 +08:00

52 lines
972 B
TypeScript

import { apiConfig } from "./api-config";
type NotificationProp = {
fcmToken: string;
title: string;
body: Object;
};
export async function apiNotificationsSend({
data,
}: {
data: NotificationProp;
}) {
try {
const response = await apiConfig.post(`/mobile/notifications`, {
data: data,
});
console.log("Fecth Notif", response.data);
return response.data;
} catch (error) {
throw error;
}
}
type DeviceTokenData = {
fcmToken: string;
platform: string;
deviceId: string;
model: string;
appVersion: string;
userId: string;
};
export async function apiDeviceRegisterToken({
data,
}: {
data: DeviceTokenData;
}) {
try {
const response = await apiConfig.post(`/mobile/auth/device-tokens`, {
data: data,
});
console.log("Device token registered:", response.data);
return response.data;
} catch (error) {
console.error("Failed to register device token:", error);
throw error;
}
}