iOS Tutorial Background Fetch (Downloads)

Discussion in 'iOS Tutorials' started by Erel, Jul 9, 2015.

  1. MarcoRome

    MarcoRome Expert Licensed User

    if you @Erel or your team or other colleagues can try the attached code in post #38 and tell me if they work.
    He doesnt work here. Tested on 2 iphone ( iphone 6s with 11.4 and xPhone )
    Perhaps because it is compiled with the B4i 5.0 version ?
    Maybe because some part of the code is wrong ?
    I dont know but anyway it doesnt work.
    Thank you again all
    Marco
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    I'm checking it. If you have a local Mac then you can monitor the logs and you will see that the OS mostly doesn't allow any app to start in the background. I'm still monitoring it to see if it will eventually run.
     
    MarcoRome likes this.
  3. MarcoRome

    MarcoRome Expert Licensed User

    Hi @Erel thank you for your time

    I tried with B4iLogger, but as you can see from the movie, after almost an hour no event ( Application_FetchDownload ) is Raised
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    What you posted is not relevant. You need to wait...
     
    Last edited: Jun 11, 2018
    MarcoRome likes this.
  5. Erel

    Erel Administrator Staff Member Licensed User

    After testing it for 24 hours I can say that it works properly.

    I've created a simple app that counts the number of times FetchDownload is called:

    Code:
    'app start
    If File.Exists(File.DirDocuments, "1.txt") = False Then
           
    File.WriteString(File.DirDocuments, "1.txt"0)
       
    End If

    Sub Application_Active
       Page1.Title = 
    "Value: " & File.ReadString(File.DirDocuments, "1.txt")
      
    End Sub

    Private Sub Application_FetchDownload
       
    Log("FetchDownload")
       
    File.WriteString(File.DirDocuments, "1.txt"File.ReadString(File.DirDocuments, "1.txt") + 1)
       
    Dim no As NativeObject = App
       no = no.GetField(
    "delegate")
       no.RunMethod(
    "completeFetch:"Array(0))
    End Sub
    Monitoring the system logs shows that many apps try to start in the background and the OS gives a score to each one. Only Apple knows how the score is calculated. I assumed that the app should be used from time to time so I started every couple of hours.
    The first FetchDownload event happened after about 12 hours. It was raised another 11 times in the following 12 hours.

    System logs:
    [​IMG]

    Don't use iReleaseLogger with fetch download as it can cause the process to fail to start.
    Don't show a notification. Maybe the OS doesn't like.

    It is probably not relevant however I used an app that also implements push notifications.
     
    MarcoRome likes this.
  6. MarcoRome

    MarcoRome Expert Licensed User

    I would say to forget it is not very reliable.
    @Erel thank you for your support and your time it's really exceptional.
    Marco
     
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