Setting Custom Login Servers in Android Apps
In Android, login hosts are known as server connections. You can see the standard list of server connections in the res/xml/servers.xml file of the SalesforceSDK project. Mobile SDK uses this file to define production and sandbox servers.
- MDM enforced
- At startup, your app’s MDM provider configures the login URI.
- The MDM policy can also hide the navigation bar and Settings icon to prevent users from changing the login host.
- App configuration through the servers.xml file
You can add your custom servers to the runtime list by creating your own res/xml/servers.xml file in your native Android project. The first server listed in your servers.xml file is used as the default login server at app startup. The root XML element for servers.xml is <servers>. This root can contain any number of <server> entries. Each <server> entry requires two attributes: name (an arbitrary human-friendly label) and url (the web address of the login server, including the “https://” prefix).
Here’s an example of a servers.xml file.
1<?xml version="1.0" encoding="utf-8"?> 2<servers> 3 <server name="XYZ.com Login" url="https://myloginserver.cloudforce.com"/> 4</servers> - User configuration through the Add Connection buttonHere’s how a user can configure a custom login server.
- Start the app without logging in.
- In the login screen, tap the Settings icon in the upper left corner.
- Tap Change Server.
- Tap Add Connection.
- To help identify this configuration in future visits, enter a name.
- Enter your custom login host’s URL. Be sure to include the https:// prefix. For example, here’s how you
enter a typical Experience Cloud site
URL:
1https://MyDomainName.my.site.com/fineapps