iOS Question file downloading not working on iphone 6/6S

elpic76

Member
Licensed User
Longtime User
Hi all,
I have a strange problem: with an iPhone 5 I'm able to successfully download a file from a remote server, while two beta tester respectively with iPhone 6 and iPhone 6S can't download it. The app is the same.

My development configuration is as follow:

B4i Version: 5.30
Hosted Builder
Java: C:\Program Files\Java\jdk1.8.0_25\bin\javac.exe
Library used:
- iBLE Version: 2.00
- iCore Version: 5.31
- iHttp Version: 1.01
- iHttpUtils2 Version: 2.62
- iHUD Version: 1.00
- iRandomAccessFile Version: 1.72

Is it possible the problem is related to the different iPhone architecture 32bit vs 64bit?
How can I solve this?
Best regards
Mosè
 

elpic76

Member
Licensed User
Longtime User
Ok I'm very happy for this ;-)

Where is the code that downloads the file?
Here the code:

B4X:
Sub VerifyServer    ' OK Android V 170
'    hdPan.ProgressDialogShow("Control for transponder update")
    hdPan.ProgressDialogShow(Starter.ResourceStrings.Get("msg_ctrl_tp_upd"))
    Dim Ver As HttpJob
    If File.Exists(File.DirDocuments,"VERSION.TXT") = True Then
        ' Applicazione connessa ma potrebbe essere stata connessa ad un diverso box rispetto a quello attuale
        ' Ritirare su la versione di FW
        ' Ritirare su la versione di TP
        ' Confronto FW e TP con quelle del box che deve comandare
        ' Modifica del file VERSION.TXT direttamente
        DebLog("Version.txt o datasat.txt esistono")
        Starter.MyMapVer = File.ReadMap(File.DirDocuments, "VERSION.TXT")
        FwStringApp = Starter.MyMapVer.Get("FWver")
        TpStringApp = Starter.MyMapVer.Get("TPver")
        Ver.Initialize("VerTp",Me)
        ' DA SERVER LOCALE
        '        Ver.Download2("http://" & Starter.ServerIP & "/www.example.com/fwswdb/verserver.php", Array As String ("action","verify","boxv",FwString,"tplv",TpString))    ' Operativo
        ' DA SERVER REMOTO
        Ver.Download2("http://www.example.com/fwswdb/verserver.php", Array As String ("action","verify","boxv",FwString,"tplv",TpString))    ' Operativo
    Else
        DebLog("Version.txt o datasat.txt non esistono")
        Ver.Initialize("VerTp",Me)
        ' DA SERVER LOCALE
        '        Ver.Download2("http://" & Starter.ServerIP & "/www.example.com/fwswdb/verserver.php", Array As String ("action","verify","boxv",FwString,"tplv",TpString))    ' Operativo
        ' DA SERVER REMOTO
        Ver.Download2("http://www.example.com/fwswdb/verserver.php", Array As String ("action","verify","boxv",FwString,"tplv",TpString))    ' Operativo
    End If
End Sub

Sub JobDone(Job As HttpJob)    ' OK Android V 170
    hdPan.ProgressDialogHide
    If Job.Success Then
        Dim res As String

        res = Job.GetString
        DebLog("Back from Job:" & Job.JobName )
        DebLog("Response from server: " & res)

        Select Job.JobName
            Case "VerTp"
                Job.Release
                If res.CompareTo("ERR") = 0 Then
                    If TpString = "19700101_000000" Then
                        cntagg = 400    ' OK senza controllo a server
                        parseOk = REQTPNAMEBOX
                        lblFoundSat.Visible = False
                        lblFoundSat.UserInteractionEnabled = False
                        lblSelSat.Visible = False
                        lblSelSat.UserInteractionEnabled = False
                        lblSat.Visible = True
                        lblSat.UserInteractionEnabled = True
'                        lblSat.Text = "Uploading Tp: "
                        lblSat.Text = Starter.ResourceStrings.Get("lbl_up_tp")&" "
               
                        ivDownload.UserInteractionEnabled = True
                        ivDownload.Width = 0
                        ivDownload.Visible = True

                        ivDownloadOff.UserInteractionEnabled = True
                        ivDownloadOff.Visible = True
                       
'                        CallSub2(Starter, "WriteData",Con.StringToBytes("GETBMEM"&CRLF,"UTF-8"))    ' ---- GESTIONE NOMI SATELLITI DA BOX
                        WriteTxRepetition("GETBMEM"&CRLF)
                    Else
'                        Msgbox("Try to download the transponder list later, list uploaded by box.","Warning")
                        Msgbox(Starter.ResourceStrings.Get("msg_down_up_tp"), Starter.ResourceStrings.Get("title_warning"))

                        cntagg = 400    ' OK senza controllo a server
                        parseOk = REQTPNAMEBOX
                        lblFoundSat.Visible = False
                        lblFoundSat.UserInteractionEnabled = False
                        lblSelSat.Visible = False
                        lblSelSat.UserInteractionEnabled = False
                        lblSat.Visible = True
                        lblSat.UserInteractionEnabled = True
'                        lblSat.Text = "Uploading Tp: "
                        lblSat.Text = Starter.ResourceStrings.Get("lbl_up_tp")&" "
               
                        ivDownload.UserInteractionEnabled = True
                        ivDownload.Width = 0
                        ivDownload.Visible = True
                   
                        ivDownloadOff.UserInteractionEnabled = True
                        ivDownloadOff.Visible = True
'                        CallSub2(Starter, "WriteData",Con.StringToBytes("GETBMEM"&CRLF,"UTF-8"))    ' ---- GESTIONE NOMI SATELLITI DA BOX
                        WriteTxRepetition("GETBMEM"&CRLF)
                    End If
                Else if res.CompareTo("OK") = 0 Then
                    DebLog("Server OK")
                    If TpStringApp.CompareTo(TpString) = 0 Then
'                        Msgbox("Transponder list is already updated.","Update")
'                        Msgbox(Starter.ResourceStrings.Get("msg_tp_ok"), Starter.ResourceStrings.Get("title_update"))
                        cnttxerr = 0
                        cntagg = 0
                        parseOk = REQIDLE
                        indiceCode = 0
                        ProgressBar1.Visible = False
                        If fpan = False Then
                            fpan = True
                            ProgressBar1.Visible = False
                            ShowInitMsg
                            tabsel = 1
                            tabstate = ALLTAB
                            TabEnable
                            timResumeTabs.Enabled = False
                            WriteTxRepetition("LSAT"&CRLF)
                            ' SE PRESSIONE DEL TASTO UPDATE E RISPONDE OK NON DEVO CAMBIARE NULLA OK
                        End If
                    Else    ' Lista Transponder App o non esiste o è diversa da quella del box
                        Dim Upd As HttpJob
                        Upd.Initialize("UpdTpApp",Me)
                        ' DA SERVER LOCALE
                        '                        Upd.Download2("http://" & Starter.ServerIP & "/www.example.com/fwswdb/verserver.php", Array As String ("action","updateapp","tpfile",TpString))
                        ' DA SERVER REMOTO
                        Upd.Download2("http://www.example.com/fwswdb/verserver.php", Array As String ("action","updateapp","tpfile",TpString))
                    End If
                Else
                    Starter.tpfilename = "DATASAT_"&res&".TXT"    ' Anche togliere info è in TpStringServer
                    TpStringServer = res
                    Dim Upd As HttpJob
                    Upd.Initialize("UpdTp",Me)
                    ' DA SERVER LOCALE
                    '                    Upd.Download2("http://" & Starter.ServerIP & "/www.example.com/fwswdb/verserver.php", Array As String ("action","update","tpfile",TpStringServer))
                    ' DA SERVER REMOTO
                    Upd.Download2("http://www.example.com/fwswdb/verserver.php", Array As String ("action","update","tpfile",TpStringServer))
                End If
            Case "UpdTpApp"
                Job.Release
                If res.CompareTo("ERR") = 0 Then
'                    Msgbox("Try to download the transponder list later, list uploaded by box.","Warning")
                    Msgbox(Starter.ResourceStrings.Get("msg_down_up_tp"), Starter.ResourceStrings.Get("title_warning"))

                    cntagg = 400    ' OK senza controllo a server
                    parseOk = REQTPNAMEBOX
                    lblFoundSat.Visible = False
                    lblFoundSat.UserInteractionEnabled = False
                    lblSelSat.Visible = False
                    lblSelSat.UserInteractionEnabled = False
                    lblSat.Visible = True
                    lblSat.UserInteractionEnabled = True
'                    lblSat.Text = "Uploading Tp: "
                    lblSat.Text = Starter.ResourceStrings.Get("lbl_up_tp")&" "
               
                    ivDownload.UserInteractionEnabled = True
                    ivDownload.Width = 0
                    ivDownload.Visible = True
                   
                    ivDownloadOff.UserInteractionEnabled = True
                    ivDownloadOff.Visible = True
'                    CallSub2(Starter, "WriteData",Con.StringToBytes("GETBMEM"&CRLF,"UTF-8"))    ' ---- GESTIONE NOMI SATELLITI DA BOX
                    WriteTxRepetition("GETBMEM"&CRLF)
                Else
                    Starter.payload = res
                    File.WriteString(File.DirDocuments, "DATASAT.TXT", Starter.payload)
                    SatNameFromFile("DATASAT_"&TpString&".TXT", False)
                    Starter.MyMapVer.Put("FWver",FwString)
                    Starter.MyMapVer.Put("TPver",TpString)
                    File.WriteMap(File.DirDocuments, "VERSION.TXT", Starter.MyMapVer)
                   
                    cnttxerr = 0
                    cntagg = 0
                    parseOk = REQIDLE
                    indiceCode = 0
                    ProgressBar1.Visible = False
                    If fpan = False Then
                        fpan = True
                        ProgressBar1.Visible = False
                        ShowInitMsg
                        tabsel = 1
                        tabstate = ALLTAB
                        TabEnable
                        timResumeTabs.Enabled = False
                        WriteTxRepetition("LSAT"&CRLF)
                    End If
                End If
            Case "UpdTp"
                Job.Release
                If res.CompareTo("ERR") = 0 Then
'                    Msgbox("Try to download the transponder list later, list uploaded by box.","Warning")
                    Msgbox(Starter.ResourceStrings.Get("msg_down_up_tp"), Starter.ResourceStrings.Get("title_warning"))
                    cntagg = 400    ' OK senza controllo a server
                    parseOk = REQTPNAMEBOX
                    lblFoundSat.Visible = False
                    lblFoundSat.UserInteractionEnabled = False
                    lblSelSat.Visible = False
                    lblSelSat.UserInteractionEnabled = False
                    lblSat.Visible = True
                    lblSat.UserInteractionEnabled = True
'                    lblSat.Text = "Uploading Tp: "
                    lblSat.Text = Starter.ResourceStrings.Get("lbl_up_tp")&" "
               
                    ivDownload.UserInteractionEnabled = True
                    ivDownload.Width = 0
                    ivDownload.Visible = True
                   
                    ivDownloadOff.UserInteractionEnabled = True
                    ivDownloadOff.Visible = True
                    CallSub2(Starter, "WriteData",Con.StringToBytes("GETBMEM"&CRLF,"UTF-8"))    ' ---- GESTIONE NOMI SATELLITI DA BOX
                    WriteTxRepetition("GETBMEM"&CRLF)
                Else
                    Starter.payload = res
                    File.WriteString(File.DirDocuments, "DATASAT.TXT", Starter.payload)
                    SatNameFromFile("DATASAT_"&TpStringServer&".TXT", True)
                End If
        End Select
    Else
        Job.Release
        DebLog("Error: " & Job.ErrorMessage)
        ' Controllo tra versioni di FW e TP tra app e box se torna allora vado aventi ugualmente senza internet
        DebLog("BOX TP: "&TpString&" FW: "&FwString)
        DebLog("APP TP: "&TpStringApp&" FW: "&FwStringApp)
        If TpString = "19700101_000000" Then
            cntagg = 400    ' OK senza controllo a server
            parseOk = REQTPNAMEBOX
            lblFoundSat.Visible = False
            lblFoundSat.UserInteractionEnabled = False
            lblSelSat.Visible = False
            lblSelSat.UserInteractionEnabled = False
            lblSat.Visible = True
            lblSat.UserInteractionEnabled = True
'            lblSat.Text = "Uploading Tp: "
            lblSat.Text = Starter.ResourceStrings.Get("lbl_up_tp")&" "
               
            ivDownload.UserInteractionEnabled = True
            ivDownload.Width = 0
            ivDownload.Visible = True
                   
            ivDownloadOff.UserInteractionEnabled = True
            ivDownloadOff.Visible = True
'            CallSub2(Starter, "WriteData",Con.StringToBytes("GETBMEM"&CRLF,"UTF-8"))    ' ---- GESTIONE NOMI SATELLITI DA BOX
            WriteTxRepetition("GETBMEM"&CRLF)
        Else If TpString.CompareTo(TpStringApp) = 0 Then
            cnttxerr = 0
            cntagg = 0
            parseOk = REQIDLE
            indiceCode = 0
            ProgressBar1.Visible = False
            ivDownload.Visible = False
            ivDownload.UserInteractionEnabled = False
            ivDownload.Width = 0
            ivDownloadOff.Visible = False
            ivDownloadOff.UserInteractionEnabled = False
            lblSat.UserInteractionEnabled = False
            lblSat.Visible = False
            lblFoundSat.UserInteractionEnabled = True
            lblFoundSat.Visible = True
            lblSelSat.UserInteractionEnabled = True
            lblSelSat.Visible = True
               
            If fpan = False Then
                fpan = True
                indSat = 0
                pckSat.SelectRow(0, indSat, True)
                selectedSat = 30
                foundSat = 30
'                lblSelSat.Text = "Last Sel: -"
                lblSelSat.Text = Starter.ResourceStrings.Get("lbl_selsat")&" -"
'                lblFoundSat.Text = "Last Found: -"
                lblFoundSat.Text = Starter.ResourceStrings.Get("lbl_foundsat")&" -"
                ProgressBar1.Visible = False
                ShowInitMsg
                tabsel = 1
                tabstate = ALLTAB
                TabEnable
                timResumeTabs.Enabled = False
                WriteTxRepetition("LSAT"&CRLF)
            End If
        Else
            Log("TPLists not comparable.")
            cntagg = 400    ' OK senza controllo a server
            parseOk = REQTPNAMEBOX
            lblFoundSat.Visible = False
            lblFoundSat.UserInteractionEnabled = False
            lblSelSat.Visible = False
            lblSelSat.UserInteractionEnabled = False
            lblSat.Visible = True
            lblSat.UserInteractionEnabled = True
'            lblSat.Text = "Uploading Tp: "
            lblSat.Text = Starter.ResourceStrings.Get("lbl_up_tp")&" "
               
            ivDownload.UserInteractionEnabled = True
            ivDownload.Width = 0
            ivDownload.Visible = True
                   
            ivDownloadOff.UserInteractionEnabled = True
            ivDownloadOff.Visible = True
'            CallSub2(Starter, "WriteData",Con.StringToBytes("GETBMEM"&CRLF,"UTF-8"))    ' ---- GESTIONE NOMI SATELLITI DA BOX
            WriteTxRepetition("GETBMEM"&CRLF)
        End If
    End If
    Return
End Sub

Is ATS enabled?
Yes, ATS is True:
B4X:
#ATSEnabled: True

Although I'm using http and not https I'm a bit confused because on iPhone 5 the download is OK while on iPhone 6/6S is KO.
The remote server is unsecure and I can't change it, so probably I've to follow the indication con ATS - App Transport Security thread, something like this:
B4X:
#PlistExtra: <key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><false/>
#PlistExtra: <key>NSExceptionDomains</key><dict>
'list the excluded domains (example.com and b4x.com)
#PlistExtra: <key>example.com</key><dict><key>NSIncludesSubdomains</key><true/><key>NSExceptionAllowsInsecureHTTPLoads</key><true/></dict>
#PlistExtra: <key>b4x.com</key><dict><key>NSIncludesSubdomains</key><true/><key>NSExceptionAllowsInsecureHTTPLoads</key><true/></dict>
'end of excluded domains
#PlistExtra: </dict>
#PlistExtra: </dict>
 
Last edited:
Upvote 0

elpic76

Member
Licensed User
Longtime User
Tip: no need to have a JobDone sub. Use Wait For instead.
Thank you for the tip I'll search in the forum to acquire more info.

Start with disabling ATS and test it again (completely disable it).
With "completely disable it" do you mean to set ATSEnabled to False or something else?
B4X:
#ATSEnabled: False

You haven't posted the iOS versions so I cannot say whether it is related or not.
The code come from my source of iOS app and because of I'm developing the same app also on Android the comments are related to a check I'm doing between Android Version and iOS Version.
Can you indicate how and what I have to post about the iOS versions to make easier for you to understand and help me?
Thank in advance.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
With "completely disable it" do you mean to set ATSEnabled to False?
Yes

Can you indicate how and what I have to post about the iOS versions to make easier for you to understand and help me?
The iPhone version is not important. The iOS version is important.
Although I'm using http and not https I'm a bit confused because on iPhone 5 the download is OK
I can only guess that the iPhone 5 is running iOS 7 or 8.
 
Upvote 0

elpic76

Member
Licensed User
Longtime User
The iPhone version is not important. The iOS version is important.
I can only guess that the iPhone 5 is running iOS 7 or 8.

I'm sorry. I didn't understand you were referencing to operating system versions.

You are right: iPhone 5 is running iOS 8 (8.4.1) while iPhone 6 and iPhone 6S are running iOS 11 (respectively 11.3.1 and 11.4.1).
 
Last edited:
Upvote 0

elpic76

Member
Licensed User
Longtime User
I'm sorry. I didn't understand you were referencing to operating system versions.

You are right: iPhone 5 is running iOS 8 (8.4.1) while iPhone 6 and iPhone 6S are running iOS 11 (respectively 11.3.1 and 11.4.1).

I disabled completely ATS and it works on all the devices iPhone5, iPhone6 and iPhone6s.
Can I publish the app on App Store If ATSEnabled is set to False or is it better if I exclude the specific domain using the following code?
B4X:
#PlistExtra: <key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><false/>
#PlistExtra: <key>NSExceptionDomains</key><dict>
'list the excluded domains (example.com and b4x.com)
#PlistExtra: <key>example.com</key><dict><key>NSIncludesSubdomains</key><true/><key>NSExceptionAllowsInsecureHTTPLoads</key><true/></dict>
#PlistExtra: <key>b4x.com</key><dict><key>NSIncludesSubdomains</key><true/><key>NSExceptionAllowsInsecureHTTPLoads</key><true/></dict>
'end of excluded domains
#PlistExtra: </dict>
#PlistExtra: </dict>
Best Regards
Mosè
 
Upvote 0
Top