iOS Adding programmatically CardDAV account

前端 未结 1 1971
一生所求
一生所求 2021-01-06 23:22

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

相关标签:
1条回答
  • 2021-01-07 00:12

    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

    0 讨论(0)
提交回复
热议问题