如何在WP8上的自定义商店上编辑联系人时收到通知

时间:2013-01-28 15:39:58

标签: windows-phone-8 store contact

我在这里面临一些严重的问题: 我正在创建一个处理联系人同步的Windows Phone 8应用程序,但我无法判断是否应该在服务器上更新本地联系人,因为我没有发现通知我的应用程序我的联系人存储中的联系人已被编辑(使用原生联系人app)。

我需要类似修订号的东西。 到目前为止我发现的是ContactChangeRecord类,但它需要一个联系人商店版本,即使联系人更改了(1),我的版本似乎总是相同的。

是的,有人能帮帮我吗?

2 个答案:

答案 0 :(得分:0)

修订号是联系商店类的属性之一。还有某种“日记”,您可以在其中检查操作类型。

答案 1 :(得分:0)

联系人商店的修订号应该更改。您可以检测到contactStore中所做的任何更改:

ContactStore cloudContactStore = await ContactStore.CreateOrOpenAsync(ContactStoreSystemAccessMode.ReadWrite, ContactStoreApplicationAccessMode.ReadOnly);

     // Assuming you already have created the contactStore and made some changes from the 
     // device like deleting, or renaming a contact
        var changeList = await cloudContactStore.GetChangesAsync(5);

        foreach (var change in changeList)
        {
            // Each change record returned contains the change type, remote and local ids, and revision number
            Debug.WriteLine(String.Format("Change Type: {0}\nLocal ID: {1}\nRemote ID: {2}\nRevision Number: {3}",
                change.ChangeType.ToString(),
                change.Id,
                await remoteIDHelper.GetUntaggedRemoteId(cloudContactStore, change.RemoteId),
                change.RevisionNumber));
            // Get the contact associated with the change record using the Id property.
            var contact = await cloudContactStore.FindContactByIdAsync(change.Id);
            if (contact != null)
            {
            }
        }

检查Visual Studio的调试输出。您应该看到联系人ID与所做的更改类型(创建,修改,删除) http://msdn.microsoft.com/en-us/library/windows.phone.personalinformation.contactchangetype.aspx

请查看此示例:http://www.getcodesamples.com/src/3D34679D/F29F8FA4了解更多详情