iOS Question Fetch download is not working for me

Humberto

Active Member
Licensed User
I write a smal app to test fetch download but the "Private Sub Application_FetchDownload" was called once in Iphone 4S ( IOS 9.3.5 ) and in an Iphone 6 ( IOS 11.2.6 ) never.

The app is in attach if someone can help me.

I´m trying to find a alternative way to receive an alarm.

The main.m is saved in Files/Special



B4X:
#Region  Project Attributes
    #ApplicationLabel: B4i Example
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #ATSEnabled: True
    #MinVersion: 7
    #PlistExtra: <key>UIBackgroundModes</key><array><string>fetch</string></array>
    
    #CertificateFile: ios_distribution_2018.cer
    #ProvisionFile: ios_ad_hoc_2018.mobileprovision
    
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page

    Private Button1 As Button
End Sub

Private Sub Application_Start (Nav As NavigationController)
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
    Page1.RootPanel.LoadLayout("main")


Dim rl As ReleaseLogger
rl.Initialize("192.168.2.102", 54323)

    App.RegisterUserNotifications(True,True,True)
    App.ApplicationIconBadgeNumber=0

    
    Dim no As NativeObject = App
    no.RunMethod("setMinimumBackgroundFetchInterval:", Array(0)) '0 = minimum interval
    
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
    
End Sub

Private Sub Application_Background
    
End Sub

Private Sub Application_FetchDownload
   Log("FetchDownload "  & App.OSVersion & " (IOS) ")
   Dim ln As Notification
   ln.Initialize(DateTime.Now)
   ln.AlertBody = "Fetch download..." & App.OSVersion & " (IOS) "
   ln.PlaySound = True
   ln.Register
 
       Dim xdata As String
    DateTime.DateFormat = "dd/MM/yyyy HH:mm:ss"
    xdata = DateTime.Date (DateTime.Now )
    
    Log  ( "**** Fetch " & App.OSVersion & " (IOS) - " & xdata )

    App.ApplicationIconBadgeNumber=2

    Sleep(5000)
Dim no As NativeObject = App
   no = no.GetField("delegate")
   no.RunMethod("completeFetch:", Array(0))
      
End Sub

Sub Button1_Click
           Dim xdata As String
    DateTime.DateFormat = "dd/MM/yyyy HH:mm:ss"
    xdata = DateTime.Date (DateTime.Now )
    
    Log  ( "**** Teste "  & App.OSVersion & " (IOS) - " & xdata )

End Sub
 

Attachments

  • Fetch.zip
    465.2 KB · Views: 122

Humberto

Active Member
Licensed User
I put the sleep command because the only time that I receive a notification with Iphone 4S I didn´t see the LOG.

The program is running all night in an Iphone 4S and Iphone 6 and I receive no notification.

Both today are connected to power and after 1 hour I get no notification.

In both case the software is running in a release mode
 
Upvote 0

Humberto

Active Member
Licensed User
After more than one hour that both phone ( 4S and 6 ) is connected to power I received 3 times whith less than 10 minutes between them in Iphone 6 but no one in Iphone 4S.

I´ll wait for one more and disconnect from power to see if I receive any.
 
Upvote 0
Top