#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