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
- Android SDK: Kotlin null Value Not Updat...
Hi team, I think you should check the Android SDK implementation once, as it seems to have an issue handling Kotlin **null** values. For example: When I send:...
- Can't connect GitHub — 500 error at the ...
Appwrite Cloud, Pro plan, SFO region. All my Git connections vanished today — Sites and all 15 Functions now show no repository connected. When I try to add a ...
- GB Hours IS NOT resetting
Hi, I was checking my usage and noticed that all of my usage quotas were reset on August 20, 2026, when my billing cycle renewed. Everything else appears to ha...