iOS Question Reachability fail

Discussion in 'iOS Questions' started by MarcelloCSI, Aug 3, 2015.

  1. MarcelloCSI

    MarcelloCSI Active Member Licensed User

    Hey guys do you know why i can't compile after added this code?
    I've added the "Reachability" libraries to the external libraries folder

    Code:
    #Region "Check WIFI"

    #If OBJC

    #import "Reachability.h"

    -(void)ReachabilityStatus
    {   
        if([[Reachability reachabilityForLocalWifi] curentReachabilityStatus] != ReachableViaWiFi)
        {
            [self.bi raiseEvent:nil event:@"Reachability_Result:" params:@"0"];
        }
        else
        {
            [self.bi raiseEvent:nil event:@"Reachability_Result:" params:@"1"];
        }
    }

    #End if

    Sub Reachability_Result(text As String)
        
    If text = "0" Then
            
    'NoWifi
            Msgbox("No wifi connection"" Wifi")
        
    Else
            
    '3G and others
            Msgbox("Wifi connection enable""Wifi")
        
    End If
    End Sub

    Sub WifiConnection
        
    Dim no As NativeObject
        no.RunMethod(
    "ReachabilityStatus:"Array(""))
    End Sub

    #End Region
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    I think that you need to include other code as well. Reachabiliy.h is not a built in header.

    Note that you can use HttpUtils2 to check whether there is internet access or not.
     
  3. MarcelloCSI

    MarcelloCSI Active Member Licensed User

    i tried it in order to get network status, in objective C Reachability library tell you if you use 3G, WiFi, etc... i need to know if the user has the Wifi connected to a network
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You can use ServerSocket.GetMyWifiIp to see whether there is a wifi connection.
     
  5. MarcelloCSI

    MarcelloCSI Active Member Licensed User

    Ok Thanks! :)
     
  6. Pendrush

    Pendrush Well-Known Member Licensed User

    Try this

    Code:
    Public Sub CheckNet As String

        
    Dim myLan As ServerSocket

        
    If myLan.GetMyWifiIP <> "127.0.0.1" Then
            
    Return("wifi")
        
    End If
       
        
    If myLan.GetMyIP <> "127.0.0.1" Then
            
    Return("3g")
        
    End If
       
        
    Return("nonet")
       
    End Sub
     
    hatzisn, ilan and Erel like this.
  7. Erel

    Erel Administrator Staff Member Licensed User

    Note that this by itself doesn't guarantee that there is an internet connection. The best solution is to first do this test and then send a request with HttpUtils2 and check the result.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice