Third-party apps in IOS app call their apps, open files

Source: Internet
Author: User

Depending on your needs, you will need to open Word, PDF, Excel and other files in your project, and add them in the Info.plist file.

<Key>Cfbundledocumenttypes</Key>    <Array>        <Dict>            <Key>Cfbundletypename</Key>            <string></string>            <Key>Lsitemcontenttypes</Key>            <Array>                <string>Com.microsoft.powerpoint.ppt</string>                <string>Public.item</string>                <string>Com.microsoft.word.doc</string>                <string>Com.adobe.pdf</string>                <string>Com.microsoft.excel.xls</string>                <string>Public.image</string>                <string>Public.content</string>                <string>Public.composite-content</string>                <string>Public.archive</string>                <string>Public.audio</string>                <string>Public.movie</string>                <string>Public.text</string>                <string>Public.data</string>            </Array>        </Dict>    </Array>

A third-party app opens a file that calls the following proxy method

/** Open File Call Agent @param application own app @param URL The sandbox address of the file when the third-party app is called @param sourceapplication the third-party app that calls our app who @param an Notation @return The return value is Yes*/-(BOOL) Application: (UIApplication *) application OpenURL: (nsurl *) URL sourceapplication: (Nullable NSString *) sourceapplication Annotation: (ID) annotation{if(Self.window) {if(URL) {nsstring*filenamestr =[url lastpathcomponent]; NSString*doc = [[Nshomedirectory () stringByAppendingPathComponent:@"Documents/localfile"] STRINGBYAPPENDINGPATHCOMPONENT:FILENAMESTR]; NSData*data =[NSData Datawithcontentsofurl:url];            [Data Writetofile:doc Atomically:yes]; NSLog (@"file is stored in a local folder"); }    }    returnYES;}

iOS calls third-party programs to open files, and third-party calls to their apps to open files

Third-party apps in IOS app call their apps, open files

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.