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 xui As XUI
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.RootPanel.LoadLayout("Page1")
NavControl.ShowPage(Page1)
App.RegisterUserNotifications(True, True, True)
End Sub
Sub Button1_Click
StartBackgroundTask
Dim no As NativeObject = App
Log("move to the background")
Sleep(5000)
Log($"Remaining time: $1.2{no.GetField("backgroundTimeRemaining").AsNumber}"$)
App.ApplicationIconBadgeNumber = Min(1000, no.GetField("backgroundTimeRemaining").AsNumber + 100)
Do While True
Log(DateTime.Now)
App.ApplicationIconBadgeNumber = App.ApplicationIconBadgeNumber - 1
Sleep(1000)
Loop
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
End Sub
Private Sub StartBackgroundTask
Dim no As NativeObject = Me
no.RunMethod("startBackgroundTask", Null)
End Sub
#if OBJC
- (void) startBackgroundTask {
UIBackgroundTaskIdentifier bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[[UIApplication sharedApplication] endBackgroundTask:bgTask];
}];
}
#End If