FirebaseAnalytics.setUserProperty() Not working.
Step 1: Describe your environment
Android Studio version: 4.1.2
Build #AI-201.8743.12.41.7042882, built on December 20, 2020
Runtime version: 1.8.0_242-release-1644-b3-6915495 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.16
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 12
Registry: ide.new.welcome.screen.force=true, external.system.auto.import.disabled=true
Non-Bundled Plugins: org.jetbrains.kotlin
Firebase Component: Cloud Messaging
Component version: com.google.firebase:firebase-messaging:20.2.4
Step 2: Describe the problem
Steps to reproduce:
Problem: User properties are not getting updated. Notifications based on User properties are receiving for wrong users.
Please follow below steps:
1. Create a project with firebase cloud messaging.
2. Make sure that you are receiving notifications from firebase console after device registration.
3. Consider a login/logout feature for your app. (Or create a button with Login / Logout).
4. Now once you tap login set some user properties. (say "user_membership": "premium").
val firebaseInstance = FirebaseAnalytics.getInstance(getAppContext()) firebaseInstance.setUserProperty("user_membership", "premium")
Note: wait for few hours to replicate user properties as per guidelines.
5. Create a Notification Campaign with user property who have premium access as below.
6. Send Notification and make sure you received notification.
7. Now tap on Logout.
8. Since we have logged out make user properties to empty value or null. (say "user_membership": "" or null).
val firebaseInstance = FirebaseAnalytics.getInstance(getAppContext()) firebaseInstance.setUserProperty("user_membership", "")
Note: wait for few hours to replicate user properties as per guidelines.
9. Do step 5 again.
10. Send notification but this time Notifications are still receiving even though we have updated user properties.
Expected: Notification should not receive after user properties have been updated.
I found a few problems with this issue:
- I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
- This issue does not seem to follow the issue template. Make sure you provide all the required information.
Even on the firebase guidelines says that setting value to null removes properties but the description says the value persists throughout app lifecycle. Setting values to null also not working and able to receive notification.
Hi @nikesh4770, thanks for the report! Setting the value to null should remove the property like you described in step 5. I've added the analytics label to this issue to help diagnose what could be going on here.
Thank you @ciarand. Funny thing is I'm able to see firebase log saying property removed but it is not. 03-02 15:29:39.636 D/FA-SVC ( 1614): Removing user property: ****.
I also tried to update value to "n/a" but still the same not updating. Once set it doesn't update.
same issue only resetAnalyticsData clear all props