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
- how think about relationships?
From what I understand, relationships don't work like foreign keys. So, two things: Is the way to simulate foreign keys to manually pass references to IDs? In...
- Appwrite - Github student plan payment
Even though I have the GitHub Student package, I received a notification saying I would be switched to a pay-as-you-go plan. (It said that I could use AppWrite ...
- SMS - Github Student Pack
I have a project on Appwrite Github Student Pack but unable to send any message as I get error: "Phone authentication limit for your organization has exceeded. ...