Push Notification Issue in Appwrite 1.5.1 with Flutter: 'bucketId' Null Error
- 0
- Self Hosted
- Flutter
- Messaging
Hello, yesterday I was able to install the new version of Appwrite 1.5.1 in self-hosted mode. Everything seems to work correctly at first glance. This morning, I wanted to try implementing push notifications.
I took an existing Flutter project and updated the SDK to 12.0.0.
The application (iOS) only allows login with an account and navigates to a page with user information.
I followed the tutorial to add push notifications with APNs.
https://appwrite.io/docs/products/messaging/send-push-notifications
I may not have understood everything (I'm not very proficient in Swift) but I think I "succeeded."
Then, in my Flutter code, I added the "createPushTarget" function with targetId I used a unique ID, and for the identifier, not knowing exactly what to put, I used the user's ID.
I launched my application, logged in with a test account, and the application asked me to accept notifications (I accepted).
I went back to my Appwrite database, and there I saw in: test user -> Target: a new line appearing with a mention of push, etc.
So, I went to the messaging section -> create message -> Push notification: entered the "title and message" fields, pressed next, selected the target (FYI, it displays poorly on Safari), selected the user, clicked next, it asked me when to send I said now, and when I pressed send, I got this error message: Cannot read properties of null (reading 'bucketId').
I don't know what's going on, can you help me? Will there be a more developed tutorial for implementation with Flutter in the coming days?
I don't know the behavior
For APNS it's undefined
For FCM, it's dependent on their APIs
There might be a bug
It's a bug, we're looking now. For now, use a production provisioning profile. I think they have something for adhoc
provisioning
If you're talking about APNs tokens, I don't know. Since yesterday, mine hasn't changed.
Very well, thank you! ! 🙂
For onesignal the token changes when you uninstall the app and reinstall. Soi wanted to know if to update target every app cycle or just on login/signup
Also can one userID have more than one pushtarget in a situtation where logges in in two phones?
I just tried it out. Indeed, when you delete and reinstall the app, the token changes. 😉
Yes, a user can have several phones and several different push tokens. It seems Appwrite handles these different push tokens because when you create a push target, you assign a unique ID.
you can send message by user
which is all compatible targets
i want to use sharedPreferences to store the token. if its null i generate a new one
In most cases we will make target_ID as user_ID, does assigning two targets with same user_id as target_ID conflict?
also the packge: plain_notification_token: ^0.0.4 you are using to generate a token, retrieves the a base64 string for ios, is there a need to decode it?
ah sorry. here's the fix: https://github.com/appwrite/console/pull/955
Awesome! 🤩 Thank you!
There's no need to decode the token.
My problem is close to being solved. I have one last question. If I'm not mistaken, currently, no client-side SDK allows sending a push notification to a user; the solution for now is to use a function on the Appwrite server, right? I may be wrong, but that seems complicated to set up. Do you think this feature will one day be directly implemented in the client-side SDK?
Never. It makes no sense to allow sending push client side because then a bad actor can spam messages
i still got an issue with tokens. if i login and create a pushtarget and then i log out and login with another account and create a push with a new user_id but will have same token. will appwrite overwrite the previous target or they both exist.
Very well, thank you, it actually makes sense. My problem is that I can’t find the logic for a user to receive a notification when an event happens (like receiving a message). I guess I will need to do some more research to fully understand 😅.
When the user logs out, the Appwrite tokens are deleted from what I've observed.
Recommended threads
- Having issues with login via CLI
``` ~/appwrite appwrite login --endpoint https://localhost/v1 --verbose ? Enter your email myvalidemai...
- Attributes Confusion
```import 'package:appwrite/models.dart'; class OrdersModel { String id, email, name, phone, status, user_id, address; int discount, total, created_at; L...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...