简体   繁体   English

如何自动将联系人与UWP应用同步?

[英]How to auto sync Contact with UWP app?

I'm using ContactPicker to pick some contacts and save in my app via SQLite. 我正在使用ContactPicker挑选一些联系人并通过SQLite保存在我的应用程序中。 1. How to sync with my app when have change Name or Phone Number in People app of phone? 1.在手机的“人”应用中更改姓名或电话号码后,如何与我的应用同步? 2. Or you have a best way to pick contacts, save and auto sync with app, please suggest me! 2.或者您有最好的方式来选择联系人,保存并与应用自动同步,请建议我!

If you want to access the contacts on the windows 10 device you can use the following code: 如果要访问Windows 10设备上的联系人,可以使用以下代码:

            var contactStore = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite);
        var contactLists = await contactStore.FindContactListsAsync();
        foreach (var cl in contactLists)
        {
            var cReader = cl.GetContactReader();
            var cBatch = await cReader.ReadBatchAsync();
            foreach (Contact c in cBatch.Contacts)
            {
                //Make a change
                c.Notes = c.Notes + c.DisplayName;
                await cl.SaveAsync();
            }
        }

This will however only allow to access the contacts that are owned by the app. 但是,这仅允许访问该应用程序拥有的联系人。 You can change ContactStoreAccessType.AppContactsReadWrite to ContactStoreAccessType.AllContactsReadWrite, but this required special deployment by Microsoft as described here: https://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.contacts.contactstoreaccesstype.aspx . 您可以将ContactStoreAccessType.AppContactsReadWrite更改为ContactStoreAccessType.AllContactsReadWrite,但这需要Microsoft进行特殊部署,如下所述: https : //msdn.microsoft.com/zh-cn/library/windows/apps/windows.applicationmodel.contacts.contactstoreaccesstype。 aspx

I you use Office 365 your contacts can also accessed and changed to outlook online. 如果您使用Office 365,您的联系人也可以访问并更改为在线Outlook。 Is this case it would much more sense to sync to office 365 using the graph.microsoft.com API (see http://graph.microsoft.io ). 在这种情况下,使用graph.microsoft.com API(请参阅http://graph.microsoft.io )同步到Office 365更加有意义。 Changes will that automatically be synced to you device. 更改将自动同步到您的设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM