iOS以编程方式添加CardDAV帐户 [英] iOS Adding programmatically CardDAV account

查看:149
本文介绍了iOS以编程方式添加CardDAV帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过编程方式添加 CardDav 帐户,因为可以通过在设置中手动使用邮件,通讯录,日历 - >添加帐户选项来完成em> app。

Is it possible to add CardDav account programmatically as it can be done by manually using Mail,Contacts,Calendras -> Add Account option in Settings app.

一般情况下,是否可以在代码中添加任何其他类型的帐户?

In general is it possible to add in code any other type of acccount?

例如交换账户。我在论坛的某个地方看到它不是。

For instance exchange account. I read that somewhere on forum that it isn't.

根据 ABSource 似乎不可能从代码中添加帐户。只有从适当的源记录中读取和复制值的函数

According with ABSource it seems that it is not possible to add account from the code. There are just functions for reading and copying values from appropriate source record

推荐答案

是的,你可以创建一个配置文件:一个plist,您可以在其中指定CardDav帐户配置文件。您可以在 Card Dav有效载荷

Yes, you can create a "configuration profile": a plist in which you can specify the CardDav account profile. You can find info about the format on the Apple Documentation under Card Dav payload.

以下是一个例子:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Inc//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>PayloadVersion</key>
    <integer>1</integer>

    <key>PayloadUUID</key>
    <string>randomUUID</string>

    <key>PayloadType</key>
    <string>Configuration</string>

    <key>PayloadIdentifier</key>
    <string>com.example.carddav</string>

    <key>Label</key>
    <string>A Carddav Profile</string>

    <key>PayloadContent</key>
    <array>
    <dict>

        <key>CardDAVAccountDescription</key>
        <string>A Carddav Description</string>

        <key>CardDAVHostName</key>
        <string>carddav.example.com</string>

        <key>CardDAVPrincipalURL</key>
        <string>/principals/userid/</string>

        <key>CardDAVUsername</key>
        <string>userId</string>

        <key>CardDAVPassword</key>
        <string>password</string>

        <key>PayloadDescription</key>
        <string>Configures CardDAV account</string>

        <key>PayloadIdentifier</key>
        <string>com.example.carddav</string>

        <key>PayloadOrganization</key>
        <string>A nice company</string>

        <key>PayloadType</key>
        <string>com.apple.carddav.account</string>

        <key>PayloadUUID</key>
        <string>randomUUID</string>

       <key>PayloadVersion</key>
       <integer>1</integer>
    </dict>
    </array>
</dict>
</plist>

请记住使用.mobileconfig保存文件。扩展。

Remember to save the file with ".mobileconfig". extension.

然后,如果您对如何以编程方式打开配置文件感兴趣,可以查看此问题
https://stackoverflow.com/questions/2338035/installin
ga-configuration-profile-on-iphone - 编程

Then if you are interested on how you can open a configuration profile programmatically, you can look at this question https://stackoverflow.com/questions/2338035/installin g-a-configuration-profile-on-iphone-programmatically

这篇关于iOS以编程方式添加CardDAV帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆