When I run my Ionic application in the browser, everything works flawlessly. I can make POST and GET requests to my local Raspberry Pi without any issues. However, when I attempt to convert my app into a real application for deployment, the connection to my Raspberry Pi fails to work. How can I enable this connectivity?
In the browser environment, my application communicates with the Raspberry Pi smoothly, indicating that the basic network configuration and interfaces are correctly set up. This includes both sending data to the Raspberry Pi and receiving data from it. The challenge arises when I try to take the next step: converting my Ionic application into a native application that can be installed on a smartphone or tablet. At this stage, the previously functional network connection to the Raspberry Pi seems to break down.
I’m looking for solutions or best practices that could help me overcome these connectivity issues. Specifically, I’m interested in whether there are any specific settings or configurations that need to be adjusted to enable communication between the native application and the Raspberry Pi. The goal is to establish a smooth and stable connection that allows my application to interact with the Raspberry Pi as a native app just as it does in the browser. How can I achieve this?
are you using http urls?
http is blocked by default since Android 9, if that’s the case you should probably be seeing “cleartext not permitted” or a similar message.
if you are using https, are the certificates properly configured?
Android devices are very sensitive to misconfigured certificates and self signed certificates don’t work at all.
Error as descibed: 2024-02-12 13:58:22.539 11521-11521 Capacitor io.ionic.starter V callback: 123357475, pluginId: App, methodName: addListener, methodData: {"eventName":"backButton"} 2024-02-12 13:58:25.853 11521-11521 Capacitor/Console io.ionic.starter E File: https://localhost/polyfills.cf419aa12150fa3f.js - Line 1 - Msg: Mixed Content: The page at 'https://localhost/home' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://192.168.10.26:2888/api/services/remote/send_command'. This request has been blocked; the content must be served over HTTPS. 2024-02-12 13:58:25.860 11521-11521 Capacitor/Console io.ionic.starter E File: https://localhost/6260.e967a105d23dc7f2.js - Line 1 - Msg: Fehler bei der Anfrage Key Command: [object Object] 2024-02-12 13:58:26.820 11521-11655 ProfileInstaller io.ionic.starter D Installing profile for io.ionic.starter
I changed it, but it does not work. My app gets this error: 024-02-12 13:58:22.539 11521-11521 Capacitor io.ionic.starter V callback: 123357475, pluginId: App, methodName: addListener, methodData: {"eventName":"backButton"} 2024-02-12 13:58:25.853 11521-11521 Capacitor/Console io.ionic.starter E File: https://localhost/polyfills.cf419aa12150fa3f.js - Line 1 - Msg: Mixed Content: The page at 'https://localhost/home' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://192.168.10.26:2888/api/services/remote/send_command'. This request has been blocked; the content must be served over HTTPS. 2024-02-12 13:58:25.860 11521-11521 Capacitor/Console io.ionic.starter E File: https://localhost/6260.e967a105d23dc7f2.js - Line 1 - Msg: Fehler bei der Anfrage Key Command: [object Object] 2024-02-12 13:58:26.820 11521-11655 ProfileInstaller io.ionic.starter D Installing profile for io.ionic.starter
Yesterday you said you got it working, now you say “error is the same”, but the image doesn’t show a mixed content error, which is what you got yesterday, so not the same error.
That looks like a javascript message with an object which logcat can’t show, you should check the actual message in chrome web inspector (put this url in your desktop chrome and select the device or emulator where you are testing chrome://inspect/#devices)
Yes it is a http url. Actually i should find a Workaround to get it working, I don´t want to publish the app in the store, so this is only for my device.
I tested all those answears what you and @twestrick wrote, but actually no one is working. You can find my repo at GitHub - mark-baumann/smart-home-app there you can see that I made capacitor config and the config at networking xml, but nothing works.