iOS Adding programmatically CardDAV account

落花浮王杯 提交于 2019-12-01 01:39:41
andreacipriani

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.

Here is an example:

<?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>

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

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!