PeerFinder.AlternateIdentities 属性

定义

获取要与其他平台上的对等应用程序匹配的备用 appId 值的列表。

public:
 static property IMap<Platform::String ^, Platform::String ^> ^ AlternateIdentities { IMap<Platform::String ^, Platform::String ^> ^ get(); };
static IMap<winrt::hstring, winrt::hstring const&> AlternateIdentities();
public static IDictionary<string,string> AlternateIdentities { get; }
var iMap = PeerFinder.alternateIdentities;
Public Shared ReadOnly Property AlternateIdentities As IDictionary(Of String, String)

属性值

IMap<String,String>

IDictionary<String,String>

IMap<Platform::String,Platform::String>

IMap<winrt::hstring,winrt::hstring>

要与其他平台上的对等应用程序匹配的备用 appId 值的列表。

Windows 要求

应用功能
ID_CAP_NETWORKING [Windows Phone] proximity ID_CAP_PROXIMITY [Windows Phone]

注解

AlternateIdentities 属性用于添加与其他平台上运行的对等应用的邻近应用 ID 匹配的备用邻近感应应用 ID。 PeerFinder 类使用备用应用 ID 将 Windows 8 计算机上运行的对等应用与在另一个平台上运行的对等应用匹配。 例如,如果你为 Windows 8 创建应用,并为Windows Phone创建相同的应用,则这两个平台上的应用将不具有相同的唯一应用 ID。 可以使用 PeerFinder 类来匹配对等应用,方法是将Windows Phone中的应用 ID 添加到 Windows 应用的 AlternateIdentities 属性,并将 Windows 应用的应用 ID 添加到Windows Phone的备用标识。

另一个平台还必须支持添加备用标识,以便可以在该平台上指定邻近应用 ID。 必须在其他平台上包含邻近应用 ID, 以便 PeerFinder 类在 Windows 设备点击时连接你的应用。 特定平台的备用标识字符串的格式由另一个平台的实现决定。 例如,若要获取Windows Phone的正确备用标识字符串,请参阅Windows Phone邻近感应 API 文档。

邻近感应应用 ID 的格式为 <包系列名称>!<应用 ID>。 可以从 Windows.ApplicationModel.Package.Current.Id.FamilyName 属性获取包系列名称。 必须从应用的程序包清单中 Application 元素的 Id 属性复制应用 ID 值。 例如,PeerFinder.Add("WindowsPhone", "{1c6379c1-9d5e-4254-8f4c-be7ea24057d1}")在 Windows 8 应用中添加Windows Phone 8 应用 ID 作为备用标识。 PeerFinder.Add("Windows", "b3c3e7ef-371a-464f-a75e-95ddbdcaf974_7fed2v891h66p!App")在 Windows Phone 8 应用中添加 Windows 8 应用 ID 作为备用标识。

在无线范围内浏览 (FindAllPeersAsync)

使用 FindAllPeersAsync 方法通过浏览无线范围内的设备来连接对等应用时,一次只能匹配一个应用 ID。 默认情况下,浏览时对等匹配使用 Windows 8 邻近感应应用 ID 。 可以通过将唯一的“浏览”应用 ID 添加到 AlternateIdentities 属性来浏览以连接在不同平台上运行的对等应用。 然后,可以将相同的“浏览”应用 ID 添加到其他平台上的对等应用。 如果“浏览”备用标识字符串匹配,则在调用 FindAllPeersAsync 方法时,PeerFinder 类可以找到对等应用。

适用于

另请参阅