将 MobileFirst Foundation SDK 添加到 Xamarin 应用程序

improve this page | report issue


概述

添加 MobileFirst 本机 SDK

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

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

创建应用程序

使用 Xamarin Studio 或 Visual Studio 创建 Xamarin 解决方案,或者使用现有的 Xamarin 解决方案。

添加 SDK

  1. 通过 Nuget Gallery/Repository 提供 MobileFirst 本机 SDK。
  2. 要导入 MobileFirst 软件包,请使用 NuGet Package Manager。 NuGet 是 Microsoft 开发平台(包括 .NET)的软件包管理器。 NuGet 客户机工具能够生成和使用软件包。 NuGet Gallery 是所有软件包作者和用户所使用的中央软件包存储库。 右键单击 Packages 目录,选择“添加软件包”,然后在搜索选项中搜索 IBM MobileFirst Platform。 选择 IBM.MobileFirstPlatformFoundation从 nuget.org 添加 sdk
  3. 单击“添加软件包”。 此操作将安装 Mobile Foundation 本机 SDK 及其依赖关系。从 nuget.org 添加 sdk

注册应用程序

  1. 装入 MobileFirst Operations Console。
  2. 单击“应用程序”旁边的“新建”按钮以注册新应用程序并遵循屏幕上的指示信息。
  3. 必须分别注册 Android 和 iOS 应用程序。 这将确保 Android 应用程序和 iOS 应用程序都可以成功连接到服务器。 可以分别在 AndroidManifest.xmlInfo.plist 中找到 Android 和 iOS 应用程序的注册详细信息。
  4. 在注册应用程序之后,浏览至该应用程序的“配置文件”选项卡,然后复制或下载 mfpclient.plistmfpclient.properties 文件。 遵循屏幕上指示信息将此文件添加到您的项目。

完成设置过程

mfpclient.plist

  1. 右键单击 Xamarin iOS 项目并选择添加文件…。浏览并找到项目根目录的 mfpclient.plist。 在提示时选择将文件复制到项目
  2. 右键单击 mfpclient.plist 文件并选择构建操作。选择内容

mfpclient.properties

  1. 右键单击 Xamarin Android 项目的资产文件夹并选择添加文件…。浏览并找到文件夹中的 mfpclient.properties。 在提示时选择将文件复制到项目
  2. 右键单击 mfpclient.properties 文件并选择构建操作。选择 Android 资产

参考 SDK

无论何时您想要使用 MobileFirst 本机 SDK,都请确保导入 Mobile Foundation 框架:

CommonProject:

using Worklight;

iOS:

using MobileFirst.Xamarin.iOS;

Android:

using Worklight.Xamarin.Android;

更新 MobileFirst 本机 SDK

要使用最新发行版更新 MobileFirst 本机 SDK,请通过 Nuget Gallery 更新 SDK 的版本。

已生成 MobileFirst 本机 SDK 工件

mfpclient.plist

此文件定义用于在 MobileFirst Server 上注册 iOS 应用程序的客户机端属性。

| 属性 | 描述 | 示例值 | |———————|———————————————————————|—————-| | protocol | 与 MobileFirst Server 的通信协议。 | http 或 https | | host | MobileFirst Server 的主机名。 | 192.168.1.63 | | port | MobileFirst Server 的端口。 | 9080 | | wlServerContext | MobileFirst Server 上应用程序的上下文根路径。 | /mfp/ | | languagePreferences | 为客户机 sdk 系统消息设置缺省语言。 | zh |

接下来要学习的教程

集成 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