Enable Custom Theming On Your Native iOS App
- How to manage custom themes on SAP Mobile Services
- How to apply custom themes to a native iOS application
- Step 1
You have built a native iOS application for the ground staff service technicians of an airline company.
Using the multi-tenancy capabilities of BTP and SAP Mobile Services, you are providing the software to two airline companies.
The airline teams are happy with your software, but they want the application to use the brand colours of their respective organizations.
You anticipate selling the software to more airlines in the future. Therefore, you don’t want to maintain multiple code-lines with custom theme for each customer.
In this tutorial, you will learn how to apply custom theme to your application without needing to re-deploy your native application. Click here to learn more about custom theme support on SAP BTP SDK iOS.
- Step 2
- Use the links mentioned in the following table to download the light and dark variants of two themes.
Name Download Link Air Line 1 Light Theme Download Air Line 1 Dark Theme Download Air Line 2 Light Theme [Download](airline_theme_2_light.zip) Air Line 2 Dark Theme Download
You can create custom themes using the UI Theme designer. Click here to learn how to create custom themes using the UI Theme Designer on SAP Cloud Portal service.
- Use the links mentioned in the following table to download the light and dark variants of two themes.
- Step 3
-
Go to your SAP Mobile Services account.
If stuck, please review the pre-requisites of this tutorial.
-
Click Mobile Applications → Settings → App Theme Manager in the sidebar.
-
Click
➕
located on the top right corner. -
Use the following table to add a new theme.
Key Value Theme Name airline_theme_1
Light Theme Upload airline_theme_1_light.zip
Dark Theme Upload airline_theme_1_dark.zip
-
Click
Save
. -
Click
➕
again. -
Use the following table to add another theme.
Key Value Theme Name airline_theme_2
Light Theme Upload airline_theme_2_light.zip
Dark Theme Upload airline_theme_2_dark.zip
-
Click
Save
. -
Enable User Selection for both themes.
The theme marked default is always available for user selection and is applied to all apps that enable custom theme.
If custom theming is enabled, at least one theme must be available for user selection.
-
- Step 4
-
Click Mobile Applications → Native/MDK in the sidebar.
-
Click New located at the top right corner.
-
Use the following table to fill the details requested in the New Application Wizard.
Key Value ID sdk.custom.theme.app
Name Custom Theme App
Description Custom Theme App
Vendor No Change License Type No Change Domain of Application Route No Change -
Click Next.
-
Click Next on the XSUAA Settings step of the Wizard without making any changes.
-
Select Native Application in the Assign Features for drop down menu.
-
Enable Mobile Sample OData ESPM by selecting the check box in the features table.
-
Click Finish.
-
- Step 5
-
Click Assigned Features → Mobile Settings Exchange.
-
Enable Enable Custom Theme check-box under the Appearance section of the Client Configuration tab.
All themes uploaded in the App Theme Manager should be visible, and the default theme is set as Active.
To add a new theme, a dark and light layout has to be uploaded.
-
- Step 6
-
Click Security tab.
-
Enable Allow Anonymous Access check-box under the Anonymous Access section.
If it is already enabled, skip to Step 7.
-
Click
➕
located above the API Key Table. -
Click OK.
If prompted, Click OK on the confirmation pop-up.
Under which tab can you find the Anonymous Access option.
-
- Step 7
-
Launch SAP BTP SDK Assistant for iOS.
-
Click Create New located near the bottom left corner.
-
Click Reuse Existing Application in the project template step.
-
Select the SAP Mobile Services account in which you created the server side configuration and click Next.
If prompted, use your SAP BTP credentials to complete the SSO login.
-
Select the app you created in the second step and click Next.
If prompted, use your SAP BTP credentials to complete the SSO login.
-
Use the following table to fill the project details requested in the Provide the Xcode project configuration step of the assistant, and click Next.
Key Value Product Name custom-theme-app
Organisation Name SAP
Organisation Identifier com.sap.ios
Bundle Identifier Auto generated Path No Change Mac Catalyst No Change -
Click Next.
-
Click Finish.
If prompted, click Trust and Open in the warning pop-up to open the newly created Xcode project.
-
- Step 8
-
Click
▶
(Start the active scheme) in Xcode to run the application. -
Toggle the appearance of your device from light to dark (or vice-versa).
Click here to see how you can toggle the appearance on a device. On a simulator, go to the Menu Bar → Features → Toggle Appearance.
-
- Step 9
-
Go to your SAP Mobile Services account.
-
Click Mobile Applications → Native/MDK in the sidebar.
-
Click sdk.custom.theme.app.
-
Click Assigned Features → Mobile Settings Exchange.
-
Select the Active radio button for
airline_theme_2
under the Appearance section of the Client Configuration tab. -
Click Save.
-
- Step 10
-
Terminate the app previously running.
-
Re-launch the app.
-
Toggle the appearance of your device from light to dark (or vice-versa).
The new application theme along with a new icon was applied without the app having to be re-deployed**.
-
- Step 11
-
Click Start.
-
Toggle appearance layout.
-
Enter your username and password.
The custom theme is not applied to the log in screen since it is not a native screen.
-
Accept user consent requests.
-
Configure a passcode.
-
Allow the app to send push notifications.
The custom theme is not applied to OS managed screens.
-
Terminate the app.
-
Switch themes on SAP Mobile Services.
-
Re-launch the app.
-
Click
ESPMContainer
. -
Toggle appearance layout.
-
Click
Suppliers
.
Congratulations on successfully completing the tutorial. You can now apply custom themes to native applications on the fly using SAP BTP SDK for iOS.
A custom theme cannot be applied to which of the following UI elements:
-
- Real world use case
- Create or download custom themes
- Upload custom themes to SAP Mobile Services
- Create a server side app configuration
- Enable a custom theme for your app on SAP Mobile Services
- Allow anonymous access for your app on SAP Mobile Services
- Build a native app capable of applying themes on the fly
- Run the app
- Change the theme of your app on SAP Mobile Services
- Re-launch the app to apply the new theme
- Experience the theme on different screens