I am writing an application linked to telegrams, I wrote a bot that creates an entry in the telegram user database, after adding the apk to the bot database, how do I make the data that I created used in the application?
@dp.message_handler(commands=['send_apk'])
async def send_apk(msg: types.Message):
user_id = msg.from_user.id
apk_file_path = "Dionis"
with open(apk_file_path, 'rb') as apk_file:
await bot.send_document(user_id, apk_file)
@dp.message_handler(commands=['bind_apk'])
async def bind_apk(msg: types.Message):
apk_file_name = msg.text.split()[1]
user_id = str(msg.from_user.id)
apk_id = str(msg.from_user.id)
apk_ref = fb.reference('/apkFiles/' + apk_id)
apk_ref.child("telegramUserId").set(user_id)
await msg.reply("Success")
myRef.addValueEventListener(object: ValueEventListener {
override fun onDataChange(snapshot: DataSnapshot) {
val userId = snapshot.child("telegramUserId").getValue(String::class.java)
if (userId != null) {
tv.text=userId
telegram.sendMessage(userId, userId)
}
}
override fun onCancelled(error: DatabaseError) {
}
})
the code in question
If I've got you right, your TG bot populates data (particulary userId) to firebase storage, now you want to set that userId to TextView in your android app.
You need to specify full referency to your child like this
"apkFiles/your_user_id/telegramUserId"or this.child("apkFiles").child("your_user_id").child("telegramUserId")see example below: