Xojo 2020 Release 2 includes API 2.0 for iOS which has many, many changes and new features.
To start, Xojo iOS projects now can use String and Variant instead of Text and Auto for better code compatibility with other Xojo projects. Along with this change, there is now an all-new set of UI components that make use of String and follow API 2.0 naming conventions.
These UI components all start with the Mobile prefix. You’ll find many of the same components you had in the past such as MobileButton, MobileTextField, MobileTextArea, etc., but you’ll also find new components such as MobileMoviePlayer and MobileMapViewer.
One important change is that equivalent to iOSView is now MobileScreen.
Speaking of MobileScreen, you can now display modal MobileScreens using the ShowModal method:
Var s2 As New Screen2
You can use Show in place of PushTo for better readability.
Var s2 As New Screen2
And you can now control whether the tab bar displays when a screen is shown by using the TabBarVisible property.
MobileApplication now has a few additions, including the ability to set the Icon Badge Number:
App.IconBadgeNumber = 42
Your app can use shortcut items (these are menus that show when you long-press on the app icon) by using AddShortcutItem and HandleShortcutItem. You can also set up the menu directly in the Capabilities Editor.
This code in HandleShortcutItem processes the shortcut that was selected and displays the appropriate screen:
Select Case shortcutType Case "Add" Var s1 As New Screen1 s1.ShortcutLabel.Text = "You selected Add New Item" App.CurrentLayout.Content = s1 Case "Favorites" Var favorites As New FavoritesScreen favorites.Show End Select Return True
You can now process URL schemes in your app. Set up the URL schema in the Capabilities Editor.
Handle the schema like this in the HandleURL event:
Var s1 As New Screen1 Var urlText As String = url.Replace("xojotest://", " ") s1.URLLabel.Text = urlText App.CurrentLayout.Content = s1
You can use the MobilePopupMessage class to show a message that will disappear after a short delay:
Var msg As New MobilePopupMessage
msg.Show("Your message has been sent.")
At long last there is now support for timed, calendar, location and remote notifications. There is a lot here, so I’ll refer you to the Notification User Guide topic for more information.
Also check out the Notification example projects in: Examples/iOS/Notifications.
New Framework Features
Much of the core Xojo framework (also sometimes called the Console framework) is available for use in your iOS apps. This includes classes such as:
- SQLiteDatabase, RowSet, DatabaseColumn, DatabaseRow
Global functions such as EncodeBase64/DecodeBase64 are also now available.
There is really far too much to cover in this one blog post, but I’ve done my best to include the highlights. Be sure to read the iOS API 2.0 Changes topic in the User Guide and try the 80+ included examples (Examples/iOS).