Add: - components/Notification/ - hooks/use-notification-store.tsx.back Fix: - app.config.js - app/(application)/(user)/_layout.tsx - app/(application)/(user)/home.tsx - app/(application)/(user)/test-notifications.tsx - app/(application)/_layout.tsx - app/_layout.tsx - components/_Icon/IconComponent.tsx - components/_Icon/IconPlus.tsx - components/_ShareComponent/NotificationInitializer.tsx - context/AuthContext.tsx - hooks/use-notification-store.tsx - ios/HIPMIBadungConnect/Info.plist - screens/Home/HeaderBell.tsx - service/api-device-token.ts - service/api-notifications.ts ### No Issue
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import { apiConfig } from "./api-config";
|
|
|
|
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,
|
|
});
|
|
|
|
return response.data;
|
|
} catch (error) {
|
|
console.error("Failed to register device token:", error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
export async function apiDeviceTokenDeleted({ userId }: { userId: string }) {
|
|
try {
|
|
const response = await apiConfig.delete(
|
|
`/mobile/auth/device-tokens/${userId}`
|
|
);
|
|
console.log("Device token deleted:", response.data);
|
|
return response.data;
|
|
} catch (error) {
|
|
console.error("Failed to delete device token:", error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
export async function apiGetAllTokenDevice() {
|
|
try {
|
|
const response = await apiConfig.get(`/mobile/auth/device-tokens`);
|
|
console.log("Device token deleted:", response.data);
|
|
return response.data;
|
|
} catch (error) {
|
|
console.error("Failed to delete device token:", error);
|
|
throw error;
|
|
}
|
|
}
|