8

I am using firebase for my mobile Android and iOS app and I want to send push notifications based on specific user properties that I set (push notifications topics don't work for my use case).

So now when I set a user property in via the app it takes forever for that change to be propagated. For example, I do have a property club which was set to a value x. I can successfully send push notifications to those users. Now when I change the value to club = y and this change will take forever to go through. Which means that all notifications sent to club = x will still be received on those devices.

To set user properties I use the firebase_analytics plugin for flutter as follows:

FirebaseAnalytics analytics = FirebaseAnalytics();
analytics.setUserProperty(name: 'club', value: 'some value')

Since I am using the user properties to set notification settings this delay is not acceptable. Does anyone know how to make this work with firebase? Or are there any guarantees at least after which amount of time these user properties get updated? I don't want to use other services such as OneSignal etc. but stay in the firebase ecosystem completely if possible.

Daniel Palenicek
  • 283
  • 1
  • 3
  • 8
  • Could you provide the code you use to change those properties? And also, how long is "too long"? It might take few seconds depending on the situation, I think. – dshukertjr Oct 02 '18 at 11:56
  • The only feasible way for this to work is to strategically use topics. The *usual* (not guaranteed AFAIK) time frame for changes in FA to propagate is 24hrs. – AL. Oct 02 '18 at 13:23
  • @AL. That's what I thought. The problem with my use case is actually, that receiving notifications is the default and I want to use user properties to _unsubscribe_ users from certain types of notifications. Users should automatically be subscribed to new topics without having to open the app. So actively unsubscribing (by setting user properties) really is the only option. But I might have to change the use case definition then. – Daniel Palenicek Oct 02 '18 at 13:49
  • From my experience you might also not have spaces in keys or values of those properties – Georg Apr 04 '22 at 10:03

1 Answers1

0

Per the Analytics doc

Note: Once the property is registered, it can take several hours for data collected with the property to be included in reports. When the new data is available, the user property can be used as a report filter or audience definition.

Which is what I assume is the cause for your delay.

Topics would be the way to go, but since as you mentioned it is not viable, you could set custom claims for the user and filter it that way as mentioned here but performance might not be great since you have to retrieve all your users first.

You could create a club collection in Firestore and for each clubName document have a toNotify subcollection containing the userIds as document name. In this context users would remove themselves from the previous clubName and create a new doc in the newClubName. Keep in mind this has the potential of causing quite a lot of read operation depending on the frequency you send notifications and the size of the your userbase.