如何以编程方式在应用程序中获取和设置 IBM MobileFirst Server 地址

how to programmatically get and set the IBM MobileFirst Server address in an app

IBM MobileFirst Platform Foundation 客户端应用程序库中是否有 API 以编程方式获取和设置应​​用程序要连接到的 WL 服务器的完整地址或 URL?

是的,你可以。从 IBM MobileFirst 6.3 开始,混合和本机 SDK 都有新的 API,可以在应用程序运行时设置和获取服务器 URL。

查看此博客 post:https://developer.ibm.com/mobilefirstplatform/2015/02/02/changing-server-url-runtime/

Stack Overflow 阻止链接让我google为您。 ;)

基本上你有两个 API:

WL.App.getServerUrl(getServerURLSuccess, getServerURLFailure)

例如:

var serverURL = $("#serverURL").val();
WL.App.setServerUrl(serverURL, setServerURLSuccess, setServerURLFailure);

就是这样。