'Code module
#Region Project Attributes
#ApplicationLabel: United
#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: 10
#End Region
#PlistExtra:<key>NSLocationWhenInUseUsageDescription</key><string>Used to display the current navigation data.</string>
#PlistExtra:<key>NSLocationUsageDescription</key><string>Used to display the current navigation data.</string>
#PlistExtra: <key>UIViewControllerBasedStatusBarAppearance</key><false/>
#PlistExtra:<key>NSPhotoLibraryUsageDescription</key><string>Select a photo.</string>
#PlistExtra:<key>NSCameraUsageDescription</key><string>Taking a photo.</string>
#PlistExtra:<key>NSMicrophoneUsageDescription</key><string>Record video.</string>
#PlistExtra:<key>NSPhotoLibraryAddUsageDescription</key><string>Save photo in albums.</string>
#CertificateFile: ios_distribution_bahoo.cer
#ProvisionFile: united.mobileprovision
#Entitlement: <key>aps-environment</key><string>production</string>
Sub Process_Globals
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private analytics As FirebaseAnalytics
Private fm As FirebaseMessaging
End Sub
Private Sub Application_Start (Nav As NavigationController)
analytics.Initialize
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
NavControl.ShowPage(Page1)
App.RegisterUserNotifications(True, True, True)
App.RegisterForRemoteNotifications
fm.Initialize("fm")
End Sub
Private Sub fm_FCMConnected
Log("FCMConnected")
'here we can subscribe and unsubscribe from topics
fm.SubscribeToTopic("ios_general") 'add ios_ prefix to all topics
LogColor (GetToken, Colors.Red)
End Sub
Sub fm_TokenRefresh(cTokenID As String)
Log( cTokenID )
End Sub
Private Sub Application_RemoteNotification (Message As Map, CompletionHandler As CompletionHandler)
Log($"Message arrived: ${Message}"$)
Msgbox(Message, "Push message!")
CompletionHandler.Complete
End Sub
Private Sub Application_Active
fm.FCMConnect 'should be called from Application_Active
End Sub
Private Sub Application_Background
fm.FCMDisconnect 'should be called from Application_Background
End Sub
Sub Application_PushToken (Success As Boolean, Token() As Byte)
Log($"PushToken: ${Success}"$)
Log(LastException)
End Sub
Private Sub GetToken As String
Dim no As NativeObject
Dim token As NativeObject = no.Initialize("FIRInstanceID").RunMethod("instanceID", Null).RunMethod("token", Null)
If token.IsInitialized Then Return token.AsString Else Return "x"
End Sub