将 MobileFirst Foundation SDK 添加到 Windows 8.1 Universal 或 Windows 10 UWP 应用程序

improve this page | report issue


概述

Mobile Foundation SDK 包含通过 Nuget 可用并且可添加到 Visual Studio 项目的依赖关系集合。 依赖关系与核心函数和其他函数对应:

  • IBMMobileFirstPlatformFoundation - 实现客户机到服务器连接,并处理认证和安全方面、资源请求及其他必需的核心函数。

在此教程中,了解如何使用 Nuget 将 MobileFirst 本机 SDK 添加到新的或现有的 Windows 8.1 Universal 应用程序或 Windows 10 UWP (Universal Windows Platform) 应用程序。 您还可以了解如何配置 MobileFirst Server 以识别应用程序,查找有关添加到项目的 MobileFirst 配置文件的信息。

先决条件:

跳转至:

添加 MobileFirst 本机 SDK

遵循下面的指示信息将 MobileFirst 本机 SDK 添加到新的或现有的 Visual Studio 项目,以将应用程序注册到 MobileFirst Server。

在您开始之前,确保 MobileFirst Server 实例正在运行。
如果使用本地安装的服务器:从命令行窗口,浏览至服务器的文件夹,并运行命令:./run.cmd

创建应用程序

使用 Visual Studio 2013/2015 创建 Windows 8.1 Universal 或 Windows 10 UWP 项目,或者使用现有项目。

添加 SDK

  1. 要导入 MobileFirst 软件包,请使用 NuGet 软件包管理器。 NuGet 是 Microsoft 开发平台(包括 .NET)的软件包管理器。 NuGet 客户机工具能够生成和使用软件包。 NuGet Gallery 是所有软件包作者和用户所使用的中央软件包存储库。

  2. 在 Visual Studio 2013/2015 中打开 Windows 8.1 Universal 或 Windows 10 UWP 项目。 右键单击项目解决方案,然后选择管理 Nuget 软件包

    Add-Nuget-tosolution-VS-settings

  3. 在搜索选项中,搜索“IBM MobileFirst 平台”。 选择 IBM.MobileFirstPlatform.8.0.0.0

    Add-Nuget-tosolution-search

    Add-Nuget-tosolution-choose

  4. 单击安装。 此操作将安装 Mobile Foundation 本机 SDK 及其依赖关系。 此步骤还将在 Visual Studio 项目的 strings 文件夹中生成空 mfpclient.resw 文件。

  5. 确保至少在 Package.appxmanifest 中启用以下功能:

    • 因特网(客户机)

手动添加 MobileFirst 本机 SDK

您还可以手动添加 Mobile Foundation SDK:

可以通过手动获取框架和库文件,准备用于开发 MobileFirst 应用程序的环境。 NuGet 还提供 Mobile Foundation SDK for Windows 8 和 Windows 10 Universal Windows Platform (UWP)。

  1. 从 MobileFirst Operations Console → 下载中心 → SDK 选项卡获得 Mobile FoundationSDK
  2. 解压缩通过步骤 1 下载的 SDK 的内容。
  3. 在 Visual Studio 中打开 Windows Universal 本机项目。 执行以下步骤。
    1. 选择工具 → NuGet Package Manager → 软件包管理器设置
    2. 选择软件包源选项。 单击 + 图标以添加新的软件包源。
    3. 提供软件包源的名称(例如windows8nuget
    4. 导航至已下载并解压缩的 MobileFirst SDK 文件夹。 单击确定
    5. 单击更新,然后单击确定
    6. 右键单击解决方案资源管理器选项卡中的解决方案项目名称(位于屏幕右侧)。
    7. 选择管理解决方案的 NuGet 软件包 → 联机 → windows8nuget
    8. 单击安装选项。 这样会显示选择项目选项。
    9. 确保选中所有复选框。 单击确定

注册应用程序

  1. 打开命令行并浏览至 Visual Studio 项目的根目录。

  2. 运行以下命令:

    mfpdev app register
    

mfpdev app register CLI 命令将先连接到 MobileFirst Server 以注册应用程序,然后更新 Visual Studio 项目内 strings 文件夹中的 mfpclient.resw 文件,并向该文件添加用来标识 MobileFirst Server 的元数据。

提示:您还可以从 MobileFirst Operations Console 注册应用程序:

  1. 装入 MobileFirst Operations Console。
  2. 单击应用程序旁边的新建按钮以注册新应用程序,并遵循屏幕上的指示信息。
  3. 注册应用程序之后,浏览至应用程序的配置文件选项卡,然后复制或下载 mfpclient.resw 文件。 遵循屏幕上指示信息将此文件添加到您的项目。

更新 MobileFirst 本机 SDK

要使用最新发行版更新 MobileFirst 本机 SDK,请在命令行窗口中从 Visual Studio 项目的根文件夹运行以下命令:

Nuget update

已生成 MobileFirst 本机 SDK 工件

mfpclient.resw

此文件位于项目的 strings 文件夹中,包含服务器连接属性,并且用户可编辑:

  • protocol – MobileFirst Server 的通信协议。 HTTPHTTPS
  • WlAppId - 应用程序的标识。 这应该与服务器中的应用程序标识相同。
  • host – MobileFirst Server 实例的主机名。
  • port – MobileFirst Server 实例的端口。
  • wlServerContext – MobileFirst Server 实例上应用程序的上下文根路径。
  • languagePreference - 为客户机 sdk 系统消息设置缺省语言。

接下来要学习的教程

集成 MobileFirst 本机 SDK 之后,您现在可以:

Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.
Last modified on June 01, 2020