feat: Implement Firebase push notifications with support for flavor-specific configurations.
This commit is contained in:
@@ -73,6 +73,39 @@ class NotificationRepository {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Register FCM token with backend.
|
||||
/// POST /notifications/fcm-token
|
||||
Future<void> registerFcmToken(String token, String device) async {
|
||||
try {
|
||||
await _dio.post('/notifications/fcm-token', data: {
|
||||
'token': token,
|
||||
'device': device,
|
||||
});
|
||||
} on DioException catch (e) {
|
||||
if (e.error is ApiException) throw e.error as ApiException;
|
||||
throw ApiException(
|
||||
message: e.message ?? 'Failed to register FCM token',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove FCM token from backend.
|
||||
/// DELETE /notifications/fcm-token
|
||||
Future<void> removeFcmToken(String token) async {
|
||||
try {
|
||||
await _dio.delete('/notifications/fcm-token', data: {
|
||||
'token': token,
|
||||
});
|
||||
} on DioException catch (e) {
|
||||
if (e.error is ApiException) throw e.error as ApiException;
|
||||
throw ApiException(
|
||||
message: e.message ?? 'Failed to remove FCM token',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class NotificationsResponse {
|
||||
|
||||
Reference in New Issue
Block a user