In application I have implemented notifications using firebase cloud message. The token generate after user login and save token in database, but when user login from other device he have diffrent token. Can I override existing token? I mean if token for this specific user exist then fetch from db and override on this device. I want have unique token for every user not for device.
CodePudding user response:
It is intentional behavior, every device generate unique token, you can also add email in the database so you can have multiple tokens or replace token based on email
If you want to achieve unique token for each device you can use
1): advertising id
2): compute DEVICE ID
val m_szDevIDShort = ("35" // we make this look like a valid IMEI Build.BOARD.length % 10 Build.BRAND.length % 10 Build.CPU_ABI.length % 10 Build.DEVICE.length % 10 Build.DISPLAY.length % 10 Build.HOST.length % 10 Build.ID.length % 10 Build.MANUFACTURER.length % 10 Build.MODEL.length % 10 Build.PRODUCT.length % 10 Build.TAGS.length % 10 Build.TYPE.length % 10 Build.USER.length % 10) // 13 digits
3): ANDROID_ID)
val m_szAndroidID = Secure.getString(this.contentResolver, Secure.ANDROID_ID)