iPhone 处理动态 URL

发布于 2024-09-29 00:40:30 字数 186 浏览 0 评论 0原文

我的 iPhone 应用程序使用 Java Web 服务来获取数据。在我的公司,我们有 3 个环境 - 开发、测试、生产。每个环境指向 Web 服务的 URL 都是不同的。因此,每次我们将项目提升到下一个环境时,我都必须更改 iPhone 代码中的硬编码 URL,以匹配目标环境的 URL。有没有人设计出一种策略来在 iPhone 本身或服务层处理这个问题?

My iPhone app consumes a Java web service in order to get data. At my company we have 3 environments - development, testing, production. Each environment's URL, that points to the web service, is different. Thus, each time we promote the project to the next environment I must change the hard-coded URL in the iPhone code to match that of the targeted environment. Has anyone devised a strategy to handle this either on the iPhone itself or in the service layer?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉酒的小男人 2024-10-06 00:40:30

尝试将 URL 的变量部分存储在应用的 info.plist 文件中。您可以更改该设置而无需重建。

如果需要更多配置更改,VCS 分支可能正是您所需要的。

Try storing the variable part of the URL in your app's info.plist file. You can change that w/o rebuilding.

If more config changes are needed, VCS branching may be what you need.

欲拥i 2024-10-06 00:40:30

您可以考虑以下方法:

  1. 当您启动应用程序时,或者更确切地说,当您确定可以建立网络连接时,您将设备 ID 发送到服务器。

  2. 服务器根据列表检查您的设备 ID,并告诉您的应用是否允许与服务器通信的用户查看开发和测试内容。

  3. 如果您的设备允许,您可以为用户提供一个界面,以更改他们是否想要查看开发、测试或生产内容。将其存储在 NSUserDefaults 中

  4. 根据用户选择,相应的 url 用于与您的服务器通信。当然,您也可以在此处包含您的设备 ID 检查。

这种方法的好处是您可以允许客户查看测试内容......而无需更新或更改他们的应用程序。您可以随时撤销该许可。

You might consider the following approach:

  1. When you start up your app, or rather when you have established that a network connection is possible, you send your device id to the server.

  2. The server checks your device id against a list and tells your app whether the user talking to the server is allowed to see development and testing content.

  3. If your device is allowed to, you provide an interface for the user to change whether they want to see development, testing or production content. Store that in NSUserDefaults

  4. Depending on user choice, the corresponding url is used to talk to your server. To be sure, you can include your device id check here, too.

This approach has the benefit that you can allow clients to see testing content... without ever having to update or change their app. And you can revoke that permission anytime.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文