I have created an application with firestore database. When user logged in or registered in application, firebase device token will be add as a field in database. At the time of logout i have put the code of delete instanceid and token too. Still i am receiving notification of previous user after logout. Here is my code.
On Registration Page:
private fun addNewUser(uid: String, socialUser: FirebaseUser? = null) {
FirebaseInstanceId.getInstance().instanceId.addOnSuccessListener(activity, OnSuccessListener<InstanceIdResult> { instanceIdResult ->
val mToken = instanceIdResult.token
userModel.deviceToken = mToken
})
val mapData = userModel.getMap()
database.collection(UserModel.COLLECTION_APP_USERS).document(uid).set(mapData, SetOptions.merge())
.addOnSuccessListener { _: Void? ->
UserTokenManager(activity).setUserMe(userModel)
isSignInSuccessful.value = ApiResponse(true)
}
.addOnFailureListener { exception: Exception ->
isSignInSuccessful.value = ApiResponse(exception)
}
}
So here i am adding token id in firestore database.
Now following code on logout.
fun endSession() {
try {
val sharedPreferenceHelper = SharedPreferenceHelper(context)
FirebaseAuth.getInstance().signOut()
FirebaseInstanceId.getInstance().deleteInstanceId()
FirebaseInstanceId.getInstance().deleteToken("7398260350" , "FCM")
SharedPreferenceHelper(context).clearAll()
val intent = Intent(this, SignInActivity::class.java)
startActivity(intent)
finish()
} catch (e: Exception) {
Log.e("exception", "==->${e.message}")
}
}
Still i am receiving notifications after logout.