Download PDF file from Firebase after QR code scan

Hello everyone,
I'm new to programing and I'm working on an app project for study. I have some issue with Firebase.
Can anyone tell me is it possible to download pdf file from Firebase storage using QR code as link to the file. I have already made Firebase storage with PDF files, and I want only registered and logged users to access to the PDF's. Registered user can only read or download file after scanning QR code ( that will be printed on the product label ). I've made basic app with login and registration forms based on tutorial's from TIMAI2 and this works fine. I can register and login user but I have no clue how to make access to the PDF files in Firebase and how to download them on app.
Is it possible at all?

Depends on your registration/login setup.

If using Firebase Authentication, then sigend in authenticated users can have access to the pdf files, when you set the secure rules correctly.

If not, then your will have to make the pdf files "freely available", and just do not share the links with anyone.

The scan of a qrCode should be possible either before or after login, which can then insitgate the download of a pdf.

Thank you for reply,

the main idea of an app is to share informations with user or service person via QR codes. For standard not logged user there will be QR code on product label that will redirect to product website that everyone can read. And for service purposes there will be another label with QR code that only logged user can scan and access to PDF file with service instructions. That's the idea.
I'm a beginer programmer and thats why I'm trying to use a little help from community to understand how to do this using MIT.
If you could show possible solution in blocks that would help a lot.


I have something like this so far.
I can scan QR code as not logged user and view link in webViewer. That is working.
and register and login as "service person", also working.
in Firebase I have already put PDF's.

You are using Firebase Authentication :wink:

Set a variable for when a user is signed in, then you can use this when the scan result is returned to determine whether a pdf download is available, whilst allowing both types of user to access the web page for the product.

I'm trying to make this working for last two days, but this forum is very helpfull, especially Your tutorials. I've learn a lot so far. If you have some example how to do this in blocks or where can I search for similar topic that'll be great. This block coding is very usefull for me to start my journey into coding android apps :grinning:

Not seen this done before, someone would have to work this up from the start.

If I get some time I will have a look at it.

Thank's in advance.
Meanwhile I'll search for more info. I have some directions from here.

What is the content of your qrCode ? Do you have an example ? (This might open another can of worms...)

frame (2)
The basic code is simply URL to product on website. This works from app and after scan from the phone camera.

and for logged users it should be like this
frame (4)
Now i can download file after scanning code with phone camera without using app. And I need to make it restricted for logged user in app only. In my app I can't download this file for now. I don't have enough code yet.

Why not just have one barcode for both, and handle the action in the app?

I was using google's qrcode generator to make the barcode, I guess you are doing something similar?

Yes. I'm making QR code by generator.
Can I make QR code for two different URL's? in one code?

The idea is to have them in different places on the product. One on the label that is visible all the time on product, and second inside where service person will look when want to install it. So they can scan code to dowload the instructions.
Maybe I'm making it more complicated than It should be but I need to have some resources available only for logged users. That is the case of study.

Yes of course, this can then be sorted out by the app with the scan result. Might need to give some thought though, if scanning outside of the app.....

You may have to do some text replacements when creating the qrcode for the pdf download from firebase storage. This is what i had to do using the google qr code generator:

  1. Text replacement for file url

  1. When barcode scanned, reverse the text replacement

As you may be able to see, this process preserves / restores %2F, &, and ?. The %2F is particularly important if your files are stored in a folder on Firebase Storage

This blocks are for scanning qr codes or generating them? I can generate QR outside the app like I did in examples. I used storage location in Firebase to create QR code. I don't know yet how to code the procedure after BarcodeScanner.AfterScan for logged user. This works for website link.


But I dont know how to do It for logged user. Still searching. You are vey kind for helping me but my knowledge is not enough yet I think.