Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing Flet app on iOS : dialog asking for permissions #1612

Closed
Michel7GitHub opened this issue Jul 21, 2023 · 15 comments
Closed

Testing Flet app on iOS : dialog asking for permissions #1612

Michel7GitHub opened this issue Jul 21, 2023 · 15 comments

Comments

@Michel7GitHub
Copy link

I am new with Flet. I installed the new IOS Flet application on my iPad (V16.5.1) and my cell phone (V16.5.1c). I am developing my Flet apps on Windows 10. I have followed the "Testing Flet app on iOS" procedure and I have a problem at the step after reading the QR code. Nothing is running. My IPad, nor my IPhone does not display the Popup "dialog asking for permissions to access your local network". However, I have another application on my iPad which communicates very well with my computer.
I tried to find a setting on my IPhone/IPad to grant access but couldn't find anything.
Do you have an idea that could help me?

@FeodorFitsner
Copy link
Contributor

My guess is that app URL built by Python Flet app is not accessible from your phone and iPad. While Flet does its best to determine computer external IP the algorithm could be non-ideal.

Take the app URL it shows in console above QR code and try opening it in the browser on your phone/iPad?

@Michel7GitHub
Copy link
Author

Safari Browser can’t open the URL.
Could it be an issue with my VPN?

@FeodorFitsner
Copy link
Contributor

Make sure both computer and phone are connected to the same wi-fi network.

@Michel7GitHub
Copy link
Author

It is

@FeodorFitsner
Copy link
Contributor

What OS is on your computer?

@Michel7GitHub
Copy link
Author

Windows 10

@FeodorFitsner
Copy link
Contributor

By default, for iOS apps Flet server is listening on port 8551. Make sure this port is enabled/allowed in Advanced Windows Firewall.

@Michel7GitHub
Copy link
Author

Original URL generated by the command FLET run —ios is
http://10.x.y.z:49930/My-app/main-py
I created an entry for port 8551 into Advanced Windows Firewall but it does’t change anything
Then, I created and other entry with port 49930 and used the following URL
http://192.168.0.163:49930/My-app/main-py
and it works
49930 is the random generated port each time I execute FLET run —ios
192.168.0.163 s my wi-fi address
10.x.y.z is my VPN address

@Michel7GitHub
Copy link
Author

Here are the conclusions of my latest research:
In any case, a port number is automatically generated each time I start "flet run --ios" on my computer (Windows 10) and causes the following problem:
In the FLET application of my Ipad, a new project is created each time a new port number is generated.
For the same project on my computer, there are as many projects with the same name on my Ipad, each having a different port number.
I then absolutely have to use the camera + QR code to start the application on my Ipad.

My VPN is causing some issues:
When my VPN is disabled on my computer (Windows 10), there is no problem except for the randomly generated port.
"flet run --ios" then generates a URL with a private IP 192.168.0.x
When my VPN is activated on my computer (Windows 10), I have to create a private network. I use NordVPN and MESH to do this. Then, there is no problem except for the randomly generated port.

You said that FLET uses a dedicated port 8551.
Should the port randomly generated by the "flet run --ios" command then be 8551?

@FeodorFitsner
Copy link
Contributor

Thanks for your efforts to further investigate this issue.

Yes, when running with --ios flag the port should default to 8551 if not specified. It must be a bug if it doesn't work on Windows - will take a look.

Re: IP detection - currently Flet uses the following code to determine IP:

import socket
hostname = socket.gethostname()
ip_addr = socket.gethostbyname(hostname)

wondering what it gives to you when VPN is on/off? Any ideas how to improve that with VPN enabled?

@FeodorFitsner
Copy link
Contributor

@Michel7GitHub Could you try using netifaces library on your machine to see what it returns? There is an instruction in the readme. I believe it could be installed into virtual env with pip install netifaces.

@Michel7GitHub
Copy link
Author

Using flet run -p 8551 --ios, I solved all my problems. No need to modify Windows Defender anymore.
VPN is not really an issue after I defined my VPN Private Network.
Your notice was clear about that : Your iOS device and computer must be connected to the same Wi-Fi or local network
I installed netifaces without problem on virtual .venv machine.

@Michel7GitHub
Copy link
Author

One last thing about your installation guide. The procedure mentions

python3 -m venv .venv
source .venv/bin/activate
  1. source is not recognized as a command
  2. The bin directory does not exist. The activate script is located in the .venv/Scripts directory.

@FeodorFitsner
Copy link
Contributor

yep, those instructions were for macOS/Linux. I will add Windows instructions as well.
random port on Windows is a bug - will fix it shortly.

@Michel7GitHub
Copy link
Author

Thank you for your time and devotion to this fantastic project. Have a nice continuity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants