No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Cordova - How to get device IP address?

    Framework
    cordova ip address
    4
    10
    2921
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • wwwizzarrdry
      wwwizzarrdry last edited by wwwizzarrdry

      I use the IP module from npm to handle all my IP address manipulation. It works fine on desktop but it just returns 127.0.0.1 on Android.

      I’ve tried the cordova-plugin-networkinterface but I can’t seem to get it to work. It appears to be dependent on the ionic framework.

      So how you go a out getting the devices local up address in Quasar/Cordova?

      1 Reply Last reply Reply Quote 0
      • ssuess
        ssuess last edited by

        Do you mean local as in local subnet? Or the IP address it appears to be to the outside world? I just use an axios call to one of the what-is-my-ip services to return that to my app, would that work?

        wwwizzarrdry 1 Reply Last reply Reply Quote 0
        • ssuess
          ssuess last edited by

          There is also this: https://stackoverflow.com/questions/20194722/can-you-get-a-users-local-lan-ip-address-via-javascript

          1 Reply Last reply Reply Quote 0
          • metalsadman
            metalsadman last edited by

            Not a quasar related issue.

            wwwizzarrdry 1 Reply Last reply Reply Quote 0
            • wwwizzarrdry
              wwwizzarrdry @metalsadman last edited by wwwizzarrdry

              @metalsadman no but in the greater context of building Cordova apps with the Quasar framework, I would entertain just about any question in these forums. It’s about sharing knowledge after all.

              I’m may case, where I connect to multiple user’s Plex servers, it’s important to know the devices LAN ip address in order to decide whether the user and their server are on the same local network or if they need to connect to it over the internet.

              Again, on desktop this is a trivial matter. I’m surprised, however, that there is no some way to get this information in Cordova. How incredibly frustrating.

              1 Reply Last reply Reply Quote 0
              • wwwizzarrdry
                wwwizzarrdry @ssuess last edited by wwwizzarrdry

                @ssuess I get the users ip address and the servers up address that they want to connect with.

                I then check if both IPs are on the same subnet. If so, I connect to the local server address. If not, I connect to the servers public address.

                1 Reply Last reply Reply Quote 0
                • ssuess
                  ssuess last edited by

                  @wwwizzarrdry maybe try installing this plugin: https://ionicframework.com/docs/v3/native/network-interface/

                  wwwizzarrdry 1 Reply Last reply Reply Quote 0
                  • wwwizzarrdry
                    wwwizzarrdry @ssuess last edited by wwwizzarrdry

                    @ssuess Thanks, that’s literally the exact plugin I referenced in the title of this post.

                    I’ve tried adding the plug-in several times, but whenever I try to call:

                    networkinterface.getWiFiIPAddress( onSuccess, onError );
                    

                    the global networkinterface object is not defined. I installed the plug-in from within the ```
                    src-cordova

                    1 Reply Last reply Reply Quote 0
                    • wwwizzarrdry
                      wwwizzarrdry last edited by wwwizzarrdry

                      If you come across this post, I was never able to get the aforementioned module to work with my quasar app.

                      However I finally stumbled upon this, which should do the trick.

                      https://github.com/kapetan/cordova-plugin-android-wifi-manager

                      https://www.npmjs.com/package/cordova-plugin-android-wifi-manager

                      Specifically,

                      getConnectionInfo(callback(err, wifiInfo))
                      

                      and

                      isWifiEnabled(callback(err, wifiEnabled))
                      
                      S 1 Reply Last reply Reply Quote 1
                      • S
                        Sifarid @wwwizzarrdry last edited by

                        @wwwizzarrdry could you give code example pls? i was try using example code from documentation that plugin, but still not working

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post