Hello guys,
I face again a problem with the account.updatePushTarget API. Now I am calling the updatePushTarget and I get the AppwriteException document_already_exists, not sure what the problem is and what the exception wants to tell me in this context. I am using the appwrite beta cloud and I make the call from my flutter mobile application my sdk version is appwrite: 13.0.0
This is my flutter code:
Future<void> setUserTarget(String? fcmToken, User user) async {
if (fcmToken == null || fcmToken.isEmpty) {
return;
}
try {
final existingPushTarget = user.targets
.where((target) => target.providerType == 'push')
.firstOrNull;
if (existingPushTarget == null) {
// Create new target
await _account.createPushTarget(
targetId: ID.unique(),
identifier: fcmToken,
providerId: PROVIDER_ID,
);
} else if (existingPushTarget.identifier != fcmToken) {
// Update existing target if token is different
await _account.updatePushTarget(
targetId: existingPushTarget.$id,
identifier: fcmToken,
);
}
} on AppwriteException catch (e, stackTrace) {
if (kDebugMode) {
print('Error setting user target: $e');
}
rethrow; // Rethrow to handle in calling code
}
}
And the response is attached in the screenshot.
Please let me know what the problem could be
Kind regards
Recommended threads
- [Solved] Appwrite project paused
I have github student account. The auth has been paused however the database is working fine. I cant see any option to resume from my console panel. It is just ...
- Missing Invoice
Hi! I need help with billing on my account (marelu@gmail.com). I have never received a single invoice by email. My organization has been on the Pro plan since...
- Appwrite Functions cold start
Hello. I'm seeing really long cold starts on Appwrite Cloud Functions and wanted to know if this is expected. My function just authenticates the user, fetches ...