iOS Question Access Network Dialog iOS - Wait for answer

Mike1970

Well-Known Member
Licensed User
Hi everyone, today I experienced an issue.
My app makes some checks online when it starts. But the first time a dialog is prompted asking to the user to allow the app to go on internet.
IMG_5156-2.jpg


the dialog is not blocking! so my program will still going in the background, failing the checks because it has not the access to the network.

There is a way to wait the user to answer?
And, there is a way to show up this dialog again if the user miss-click and tap on "not allow"?


Thanks in advance
 

Alex_197

Active Member
Licensed User
Hi everyone, today I experienced an issue.
My app makes some checks online when it starts. But the first time a dialog is prompted asking to the user to allow the app to go on internet.
View attachment 106269

the dialog is not blocking! so my program will still going in the background, failing the checks because it has not the access to the network.

There is a way to wait the user to answer?
And, there is a way to show up this dialog again if the user miss-click and tap on "not allow"?


Thanks in advance
I had the same problem. On start I need to download privacy statement from the web site to show on the screen. My problem was that I sent a POST request to the server that pulled privacy statement from the web site and replied with html.

I fixed it by pulling statement directly from the web site by using DownLoadString which works regardless of the user's answer.

Check if it will work for you. If you need to send a POST request - The only thing I see is to create some new form that will be shown as a first screen that doesn't do anything on the Internet. So before you will go to the Internet your user will allow Internet connection.
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
I had the same problem. On start I need to download privacy statement from the web site to show on the screen. My problem was that I sent a POST request to the server that pulled privacy statement from the web site and replied with html.

I fixed it by pulling statement directly from the web site by using DownLoadString which works regardless of the user's answer.

Check if it will work for you. If you need to send a POST request - The only thing I see is to create some new form that will be shown as a first screen that doesn't do anything on the Internet. So before you will go to the Internet your user will allow Internet connection.
thanks for answering, at the moment i already use .Download method :(
 
Upvote 0

Alex_197

Active Member
Licensed User
thanks for answering, at the moment i already use .Download method :(

.Download method works for me - I see downloaded string even before allowed Internet connection


B4X:
Private Sub GetLegal
    
    Try
        Dim j As HttpJob
        Dim str As String
        
        
        hud.ProgressDialogShow("Starting")
        
        
        j.Initialize("",Me)

        j.Download("https://www.hcms-evv.com/medical-billing-services-terms-of-use")
                
        Wait For(j)    JobDone(j As HttpJob)
        
        If j.Success Then
            
            str=j.GetString
            
            TOSStr=str
        
            wvTOS.LoadHtml(str)
        
            
        Else
            
            Msgbox("Please check your Internet connection or allow the Network connection and restart the application.","HCMS")
            str="NoConnection"
        End If
        
        j.Release
        
        If str="NoConnection" Then
            hud.ProgressDialogHide
            Return
        End If
        
        
        Dim j As HttpJob
        Dim str As String
        
        
        
        j.Initialize("",Me)

        j.Download("https://www.hcms-evv.com/medical-billing-services-privacy-policy")
        
        Wait For(j)    JobDone(j As HttpJob)
        
        If j.Success Then
            
            str=j.GetString
            PrivacyStr=str
            
        Else
            
            Msgbox("Please check your Internet connection","HCMS")
            
        End If
        
        j.Release
        
        
        
        hud.ProgressDialogHide
        
        If TOSAccepted=False Then
            btnNext.Text="Accept Terms Of Use"
            pg.Title="Terms of Use"
            
        End If
        
    Catch
        Log("Leagal_GetLegal " & LastException.description)
        
    End Try
    
End Sub
 
Last edited:
Upvote 0

roumei

Active Member
Licensed User
Can you please show your code requesting the permission? I don't know what kind of permission you request but I solved a similar problem for the GPS/location permission request.
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Can you please show your code requesting the permission? I don't know what kind of permission you request but I solved a similar problem for the GPS/location permission request.

it's not ME that fires that request, it shows automatically D:
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
.Download method works for me - I see downloaded string even before allowed Internet connection


B4X:
Private Sub GetLegal
   
    Try
        Dim j As HttpJob
        Dim str As String
       
       
        hud.ProgressDialogShow("Starting")
       
       
        j.Initialize("",Me)

        j.Download("https://www.hcms-evv.com/medical-billing-services-terms-of-use")
               
        Wait For(j)    JobDone(j As HttpJob)
       
        If j.Success Then
           
            str=j.GetString
           
            TOSStr=str
       
            wvTOS.LoadHtml(str)
       
           
        Else
           
            Msgbox("Please check your Internet connection or allow the Network connection and restart the application.","HCMS")
            str="NoConnection"
        End If
       
        j.Release
       
        If str="NoConnection" Then
            hud.ProgressDialogHide
            Return
        End If
       
       
        Dim j As HttpJob
        Dim str As String
       
       
       
        j.Initialize("",Me)

        j.Download("https://www.hcms-evv.com/medical-billing-services-privacy-policy")
       
        Wait For(j)    JobDone(j As HttpJob)
       
        If j.Success Then
           
            str=j.GetString
            PrivacyStr=str
           
        Else
           
            Msgbox("Please check your Internet connection","HCMS")
           
        End If
       
        j.Release
       
       
       
        hud.ProgressDialogHide
       
        If TOSAccepted=False Then
            btnNext.Text="Accept Terms Of Use"
            pg.Title="Terms of Use"
           
        End If
       
    Catch
        Log("Leagal_GetLegal " & LastException.description)
       
    End Try
   
End Sub
i did like so, the message still appear on first time, and if i did not answer the question, the app still tries to connect, but, it can't because i did not allowed it to go on internet yet :(
 
Upvote 0

Alex_197

Active Member
Licensed User
I tried to compile the app in Release mode, that dialog does not appear anymore, I think is something related with B4i-Bridge at this point
install your app in release mode, than delete, then install again - you will see it.

The funniest thing that even if your app doesn't need the Internet at all you will be asked right after the installation to allow Internet connection
 
Upvote 0

Alex_197

Active Member
Licensed User
i did like so, the message still appear on first time, and if i did not answer the question, the app still tries to connect, but, it can't because i did not allowed it to go on internet yet :(
Put some form before, like a splash screen and you will be asked earlier.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
When an app starts, it can send broadcast UDP packet and to wait UDP_PacketArrived.
If there is no response during some seconds, repeat UDP packet . If there is no response during, let's say, 1 minute, this means that user did not allow access or did not reply to question.
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
When an app starts, it can send broadcast UDP packet and to wait UDP_PacketArrived.
If there is no response during some seconds, repeat UDP packet . If there is no response during, let's say, 1 minute, this means that user did not allow access or did not reply to question.
ok, maybe I can use it to check if it was denied. but in this case I should show that dialog again to ask a second time.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Apple does not offer public API to manipulate with this permission. User can reset a permission outside your program (using Settings).
In these conditions an app can do following. When starts, it sends UDP package and shows a splash screen. If no UDP_PacketArrived during 1-2 seconds an app shows a warning in the midddle of splash screen with a text (Please, allow access to local network).

Imagine the first start of the app. User will see a system dialog only (which will cover your warning). If user will not allow access, he will see your message only.
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Apple does not offer public API to manipulate with this permission. User can reset a permission outside your program (using Settings).
In these conditions an app can do following. When starts, it sends UDP package and shows a splash screen. If no UDP_PacketArrived during 1-2 seconds an app shows a warning in the midddle of splash screen with a text (Please, allow access to local network).

Imagine the first start of the app. User will see a system dialog only (which will cover your warning). If user will not allow access, he will see your message only.
ok thanks for the suggestion Semen and Alex:)
 
Upvote 0
Top