Ionic framework - detect internet connection - angularjs

I am developing simple application using Ionic framework (and AngularJs) that fetches json data from my webpage. How can I detect is there "internet connection" and display message to user: "Connect to internet" if not.
EDIT
Can I use cordova API for that ?

Cordova provides org.apache.cordova.network-information plugin.
See documentation HERE
This plugin provides an implementation of an old version of the Network Information API. It provides information about the device's cellular and wifi connection, and whether the device has an internet connection.

If I am not mistaken, this plugin only detects whether the Wi-Fi or Cellular networking is enabled on the device. This does not always mean that the application can actually reach your remote server, if you are connected to the WiFi network without internet connection.
Therefore, the only solution I have found to ensure that the application can reach your remote server is to continuously ping the server.

Related

Connect to the Wi-Fi network from within the app without internet access

I am developing hotspot helper application which tries to connect to the captive network after connecting to it, I need to handle the authentication within the app.
Approach 1
I used NEHotspotConfigurationManager in order to programmatically connect to the WiFi network and it works great. The problem i am facing is after connecting to the captive network iOS does not send the request to the connected network until the connected network has internet access or I manually go to the settings and it pops up the web page for authentication and i click cancel and select use without internet.
Approach 2
Second approach i used is by using NEHotSpotHelper as described in this tutorial
In this approach when I receive the commandType authenticate it does not send request to the Wi-Fi network (If the device is connected to the 4g the request goes over it otherwise it returns internet connection appears to be offline)
So how can i authenticate the user from the app after connecting to the WiFi with limited access?
I found that developer need to bind the request with the received command before making web request to the connected network. All you need to do is to make NSMutableURLRequest and then call hitTestURLRequest.bind(to: command) because bind function is defined in the category of NSMutableURLRequest.
Related question: https://stackoverflow.com/a/50753526/1796092

rails server successfully, but can't access in mobile

Iam able to access rails app in all systems with in network, but unable to access in mobiles.
I started app like below
rails s -b ip
Double check if your mobile is in the same network of your server. You can do this either by pinging your mobile device (if it support ping) or doing a network scan using tools like nmap or take a look at your router to see where is your device. If you want to allow all access, the binding ip should be 0.0.0.0.

Localhost and Ionic View

I am testing in my browser using Ionic Serve and I am also connecting to a RESTful WCF Service running on a Localhost. I want to be able to connect to that service using the Ionic View App. Is it possible to connect to a local host with an external device like using Ionic view app on my device or do I need to host my service differently?
computer and device on same network
goto computer command prompt and run this command ipconfig
you will get internet ip address like e.g:192.168.0.102
now move to your device set http:// 192.168.0.102:yourapilink?parameters=1
please like if answer really helpfull
There are tools available, but most easy way will be this:
Make sure both computer and mobile are on same network.
Run server on localhost, and in client side code replace localhost with the IP address of your system where you are making api calls. For example localhost/api/login with 192.168.1.102/api/login.
Now your mobile will be getting response from server running on your system.

Monitor URLs accessed by mobile app

I have downloaded an Android app (which is also available for iPhone and ipad). I want to monitor which URLs it is accessing. On the desktop, you can use tools like Chrome dev tools for browser traffic and Charles Proxy (http://www.charlesproxy.com/) for other app traffic. Is there a similar way to set a proxy for the app from outside it, and then view any connection attempts, possibly with headers and responses?
I only need to do it once, to ensure the app isn't malicious, so the process doesn't have to be the most convenient method in the world. For example, it could involve setting up a proxy app on the desktop and then connecting through that, or running the Android or iOS version on a desktop-based simulator and monitoring that.
When searching SO, a lot is to be found on this topic. The best solution seems to be setting up a desktop to be an access point for the android device and run wireshark on it like suggested here
Capturing mobile phone traffic on wireshark
your best bet is charles proxy trial version
to set up charles proxy is like butter
1) Make sure both computer and device are on the same network
2) Download charles proxy on computer
3) On device go to wifi--> connection name--> hold on to it --> modify --> manual proxy --> give your ip address and port 8888
4) keep charles open on computer while you are doing this
5) you will get a pop up in charles regarding the connection and will start showing you the traffic being captured from the app..

Connecting to device behind firewall

I have a wpf app that needs to communicate(exchange data) with a custom designed device (we can modify the code for the device). Do I have any options to connect to the device if it is behind a firewall via http? I was hoping there would be a method where the admin would not have to forward any specific ports or do anything on his end. I assume the issue is how would I address the device from my app. I know SOAP over SMTP is one option. Is another option where the device could chatter out to my application via http?
This problem is solved by relay services like Yaler or My-devices (I did not test this last one).
UPNP is supported by some firewalls to simplify this. Otherwise you are usually stuck opening ports on the firewall manually or using some 3rd party proxy server for a rendezvous server.
A lot of firewalls are setup to allow access on port 80 (HTTP) otherwise the users wouldn't be able to browse web sites on the internet. You can try and see if port 80 is open to traffic. If you can modify the code for both the device and the client you can use port 80 to communicate with your own protocol - you don't necessarily need to use HTTP.
Any kind of RESTful architecture over http will do it. If this is the best option for you depends on what APIs / libraries are available on your custom device.

Resources