@amityco/ts-sdk-react-native
Version:
Amity Social Cloud Typescript SDK
27 lines (22 loc) • 683 B
text/typescript
import { getDeviceId } from '~/core/device';
import { getActiveClient } from './activeClient';
import { ASCApiError } from '~/core/errors';
export const unregisterPushNotification = async (): Promise<boolean> => {
const client = getActiveClient();
const deviceId = getDeviceId();
const {
data: { status, error },
} = await client.http.delete<{ status: 'success' | 'error'; error?: string }>(
'/v1/notification',
{
data: {
deviceId,
},
headers: { 'X-API-Key': client.apiKey },
},
);
if (error) {
throw new ASCApiError(error, Amity.ServerError.BUSINESS_ERROR, Amity.ErrorLevel.ERROR);
}
return status === 'success';
};