Source language: Translate to:

IP address recognition

General questions about NeoAppBuilder - our rapid application development tool for building HTML5, web and mobile apps.

Moderator: Neosoft Support

IP address recognition

Postby HackinHoodLogicsTm » Fri Feb 02, 2018 4:34 am

Hi NAB,

Please is it possible to retrieve the IP address from your network and store it in a text field?
Please, any help will be appreciated.

Thanks a lot
I am proud to be a Neobooker!!!
www.neosoftware.com
Special Thanks To
Mr. David Riley
User avatar
HackinHoodLogicsTm
 
Posts: 126
Joined: Wed Aug 28, 2013 7:03 am
Location: Ghana

Re: IP address recognition

Postby anton » Sun Feb 04, 2018 11:51 pm

js - can not receive this information, it is necessary to use server languages ​​for this. Or use a third-party service:

Go to the next path and write:

Project>Events...>start-up

BeginJS
var script=document.createElement('script');
script.src='http://ip-jobs.staff-base.spb.ru/ip.cgi';
document.getElementsByTagName('head')[0].appendChild(script);
EndJS


Then, at the event, press the button, write:

BeginJS
$rootScope.myip = IP;
EndJS

Thus, you put the IP address of the current user of the page of your program into the variable [myip].
User avatar
anton
 
Posts: 64
Joined: Fri Oct 19, 2012 9:21 pm

Re: IP address recognition

Postby farhad2008 » Mon Feb 05, 2018 1:39 am

not work
The Words I Love You
farhad2008
 
Posts: 52
Joined: Tue Apr 01, 2008 1:15 am
Location: usa

Re: IP address recognition

Postby anton » Mon Feb 05, 2018 8:26 am

farhad2008 wrote:not work

working
https://youtu.be/SbfaZlrVlP8
User avatar
anton
 
Posts: 64
Joined: Fri Oct 19, 2012 9:21 pm

Re: IP address recognition

Postby farhad2008 » Mon Feb 05, 2018 1:06 pm

yes
working for me
thank you
The Words I Love You
farhad2008
 
Posts: 52
Joined: Tue Apr 01, 2008 1:15 am
Location: usa

Re: IP address recognition

Postby HackinHoodLogicsTm » Mon Feb 05, 2018 4:20 pm

Thank you a lot @anton

This code works perfectly but the only problem I have is that I need the local IP address, not the Public IP Address.
Please, any Idea how?
I am proud to be a Neobooker!!!
www.neosoftware.com
Special Thanks To
Mr. David Riley
User avatar
HackinHoodLogicsTm
 
Posts: 126
Joined: Wed Aug 28, 2013 7:03 am
Location: Ghana

Re: IP address recognition

Postby anton » Tue Feb 06, 2018 12:17 am

HackinHoodLogicsTm wrote:Thank you a lot @anton

This code works perfectly but the only problem I have is that I need the local IP address, not the Public IP Address.
Please, any Idea how?


To obtain local IP, you can use the following code:

window.RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
var pc = new RTCPeerConnection({iceServers:[]}), noop = function(){};
pc.createDataChannel("");
pc.createOffer(pc.setLocalDescription.bind(pc), noop);
pc.onicecandidate = function(ice){
if(!ice || !ice.candidate || !ice.candidate.candidate) return;
var myIP = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/.exec(ice.candidate.candidate)[1];
$rootScope.myIP = myIP;
pc.onicecandidate = noop;
};

!!!!!!!!!!!!!!! Does not work in IE and Edge ... As always ... !!!!!!![/quote]

Tutorial:
https://youtu.be/bGylNJt8KWY
User avatar
anton
 
Posts: 64
Joined: Fri Oct 19, 2012 9:21 pm

Re: IP address recognition

Postby HackinHoodLogicsTm » Tue Feb 06, 2018 4:53 am

Thank you @anton. You are Genius :D
I am proud to be a Neobooker!!!
www.neosoftware.com
Special Thanks To
Mr. David Riley
User avatar
HackinHoodLogicsTm
 
Posts: 126
Joined: Wed Aug 28, 2013 7:03 am
Location: Ghana

Re: IP address recognition

Postby HackinHoodLogicsTm » Tue Feb 06, 2018 5:19 am

Ooops the code works well on the browser but when compiled to the android app.

I get this "fd88:4477:7aa7:a800:e07e;xxxxx" instead of the ip.

Please, any ideas why?
I am proud to be a Neobooker!!!
www.neosoftware.com
Special Thanks To
Mr. David Riley
User avatar
HackinHoodLogicsTm
 
Posts: 126
Joined: Wed Aug 28, 2013 7:03 am
Location: Ghana

Re: IP address recognition

Postby anton » Tue Feb 06, 2018 7:52 am

HackinHoodLogicsTm wrote:Ooops the code works well on the browser but when compiled to the android app.

I get this "fd88:4477:7aa7:a800:e07e;xxxxx" instead of the ip.

Please, any ideas why?


Excellent. This is IPv6. It turns out that on the android is used not IPv4 and IPv6.
User avatar
anton
 
Posts: 64
Joined: Fri Oct 19, 2012 9:21 pm


Return to General NeoAppBuilder Discussion

Who is online

Users browsing this forum: No registered users and 2 guests