I have been experimenting with Background Fetch as per the instructions here (2015 Tutorial by Erel) and have been unable to get it to work at all:
www.b4x.com
Since it is an old post, I have searched the forum for any updates on this but have been able to find any. The only thing I found was a later post that perhaps went unnoticed, which provided the following link to Apple Developer that indicates that "setMinimumBackgroundFetchInterval" has been deprecated for IOS 7-13 and says - For apps supporting iOS 13 and higher use BGAppRefreshTask.
developer.apple.com
Does anyone know of any examples that use this to achieve the same results?
BTW... my test program mentioned above that does not work is pretty much an exact duplicate of Erel's in the Tutorial mentioned above. I just added a counter to count the number of times the Application_FetchDownload() sub is accessed and a button to display the count to check the value. I have the program running on my phone for two days and the counter has not incremented.
Background Fetch (Downloads)
Background fetch feature allows applications to run for a short period of time (up to 30 seconds) while in the background. The steps required to use this service are: 1. Add the fetch mode declaration: #PlistExtra: UIBackgroundModesfetch 2. Download the attached zip file and copy main.m to...
Since it is an old post, I have searched the forum for any updates on this but have been able to find any. The only thing I found was a later post that perhaps went unnoticed, which provided the following link to Apple Developer that indicates that "setMinimumBackgroundFetchInterval" has been deprecated for IOS 7-13 and says - For apps supporting iOS 13 and higher use BGAppRefreshTask.
setMinimumBackgroundFetchInterval(_:) | Apple Developer Documentation
Specifies the minimum amount of time that must elapse between background fetch operations.
Does anyone know of any examples that use this to achieve the same results?
BTW... my test program mentioned above that does not work is pretty much an exact duplicate of Erel's in the Tutorial mentioned above. I just added a counter to count the number of times the Application_FetchDownload() sub is accessed and a button to display the count to check the value. I have the program running on my phone for two days and the counter has not incremented.
Test Program:
#Region Project Attributes
#ApplicationLabel: Background Fetch
#Version: 1.0.0
#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#PlistExtra: <key>UIBackgroundModes</key><array><string>fetch</string></array>
#End Region
Sub Process_Globals
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
' For testing:
Private cnt as int
Private btnRefresh As B4XView
Public TextView1 As TextView
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
NavControl.ShowPage(Page1)
Dim no As NativeObject = App
no.RunMethod("setMinimumBackgroundFetchInterval:", Array(0))
End Sub
Private Sub Application_FetchDownload
Log("FetchDownload")
Dim ln As Notification
ln.Initialize(DateTime.Now)
ln.AlertBody = "Fetch download..."
ln.PlaySound = True
ln.Register
cnt = cnt+1 'see how many times this sub is accessed'
Dim no As NativeObject = App
no = no.GetField("delegate")
no.RunMethod("completeFetch:", Array(0))
End Sub
Private Sub btnRefresh_Click
TextView1.Text = ctr
End Sub