Back

Push Notification Issue in Appwrite 1.5.1 with Flutter: 'bucketId' Null Error

  • 0
  • Self Hosted
  • Flutter
  • Messaging
kadabra40
9 Mar, 2024, 10:34

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?

TL;DR
Developers are experiencing issues with push notifications in Appwrite 1.5.1 with Flutter, particularly regarding 'bucketId' null errors, token handling, and target conflict resolution. The solution involves updating to 1.5.2 and addressing how tokens are generated and targets are handled. The use of plain_notification_token may need decoding for iOS, and the client-side SDK for push notifications may need server-side functions in Appwrite. Sandbox mode activation in APNs can be problematic due to provisioning profile issues.
VincentGe
11 Mar, 2024, 14:36

I don't know the behavior

VincentGe
11 Mar, 2024, 14:36

For APNS it's undefined

VincentGe
11 Mar, 2024, 14:36

For FCM, it's dependent on their APIs

VincentGe
11 Mar, 2024, 14:37

There might be a bug

VincentGe
11 Mar, 2024, 14:40

It's a bug, we're looking now. For now, use a production provisioning profile. I think they have something for adhoc provisioning

kadabra40
11 Mar, 2024, 14:45

If you're talking about APNs tokens, I don't know. Since yesterday, mine hasn't changed.

kadabra40
11 Mar, 2024, 14:46

Very well, thank you! ! 🙂

frankenstein
11 Mar, 2024, 14:48

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

frankenstein
11 Mar, 2024, 14:49

Also can one userID have more than one pushtarget in a situtation where logges in in two phones?

kadabra40
11 Mar, 2024, 14:50

I just tried it out. Indeed, when you delete and reinstall the app, the token changes. 😉

kadabra40
11 Mar, 2024, 14:54

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.

VincentGe
11 Mar, 2024, 14:56

you can send message by user

VincentGe
11 Mar, 2024, 14:56

which is all compatible targets

frankenstein
11 Mar, 2024, 14:59

i want to use sharedPreferences to store the token. if its null i generate a new one

frankenstein
11 Mar, 2024, 15:00

In most cases we will make target_ID as user_ID, does assigning two targets with same user_id as target_ID conflict?

frankenstein
11 Mar, 2024, 15:02

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?

Steven
11 Mar, 2024, 15:16
kadabra40
11 Mar, 2024, 15:27

Awesome! 🤩 Thank you!

kadabra40
11 Mar, 2024, 15:29

There's no need to decode the token.

kadabra40
11 Mar, 2024, 15:51

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?

Steven
11 Mar, 2024, 15:52

Never. It makes no sense to allow sending push client side because then a bad actor can spam messages

frankenstein
11 Mar, 2024, 15:56

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.

kadabra40
11 Mar, 2024, 15:58

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 😅.

kadabra40
11 Mar, 2024, 16:00

When the user logs out, the Appwrite tokens are deleted from what I've observed.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more