#Region Project Attributes
#ApplicationLabel: Push Parsing
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#ProvisionFile: Push.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 Const ServerUrl As String = "http://www.push_server/"
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "MyTitle"
Page1.RootPanel.Color = Colors.White
NavControl.ShowPage(Page1)
App.RegisterUserNotifications(True, True, True)
App.RegisterForRemoteNotifications
App.ApplicationIconBadgeNumber = 5
End Sub
Private Sub Application_PushToken (Success As Boolean, Token() As Byte)
If Success Then
Dim bc As ByteConverter
Dim j As HttpJob
Log ("Token: " & bc.HexFromBytes(Token))
j.Initialize("j", Me)
j.PostString(ServerUrl & "/devicetoken", "token=" & bc.HexFromBytes(Token) & "&type=1")
Else
Log("Error getting token: " & LastException)
Msgbox("Error getting token: " & LastException, "Debug")
End If
End Sub
Private Sub JobDone(Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success & ", Tag = " & Job.Tag)
If Job.Success Then
Log(Job.GetString)
Log("Token uploaded successfully.")
Else
Log("Error uploading token")
End If
Job.Release
End Sub
Private Sub Application_RemoteNotification (Message As Map)
Dim ApsMap As Map = Message.Get("aps")
Log("Aps=" & ApsMap)
Dim AlertMap As Map = ApsMap.Get("alert")
Log("Alert=" & AlertMap)
Dim BodyText As String = AlertMap.Get("body")
Log("Body=" & BodyText)
Dim TitleText As String = AlertMap.Get("title")
Log("Title=" & TitleText)
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
End Sub
Private Sub Application_Background
End Sub