User Pages - app/(application)/(user)/home.tsx - app/(application)/(user)/portofolio/[id]/index.tsx - app/(application)/(user)/profile/[id]/index.tsx Home - screens/Home/bottomFeatureSection.tsx Components - components/Notification/NotificationInitializer.tsx - components/_ShareComponent/SkeletonCustom.tsx Service - service/api-device-token.ts Config & iOS - app.config.js - ios/HIPMIBadungConnect.xcodeproj/project.pbxproj - ios/HIPMIBadungConnect/Info.plist ### No Issue
53 lines
1.3 KiB
TypeScript
53 lines
1.3 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);
|
|
|
|
return response.data;
|
|
} catch (error: any) {
|
|
console.error("Failed to register device token:", error);
|
|
console.error("Response data:", error?.response?.data);
|
|
console.error("Response status:", error?.response?.status);
|
|
console.error("Request payload:", data);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
export async function apiDeviceTokenDeleted({ userId, deviceId }: { userId: string, deviceId: string }) {
|
|
try {
|
|
const response = await apiConfig.delete(
|
|
`/mobile/auth/device-tokens/${userId}?deviceId=${deviceId}`
|
|
);
|
|
|
|
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`);
|
|
|
|
return response.data;
|
|
} catch (error) {
|
|
console.error("Failed to delete device token:", error);
|
|
throw error;
|
|
}
|
|
}
|