iOS APP中第三方APP調用自己的APP,開啟檔案

來源:互聯網
上載者:User

標籤:根據   window   poi   檔案夾   content   .net   cal   osi   hive   

根據需求需要在項目中要開啟word、pdf、excel等檔案,在info.plist檔案中添加

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

第三方應用開啟檔案會調用下面的代理方法

/** 開啟檔案調用的代理方發  @param application 自己的app @param url 第三方應用調用時檔案的沙箱地址 @param sourceApplication 調用我們APP的第三方應用是誰 @param annotation @return 傳回值是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(@"檔案已存到本地檔案夾內");        }    }    return YES;}

 

ios調用第三方程式開啟檔案,以及第三方調用自己的APP開啟檔案

 

iOS APP中第三方APP調用自己的APP,開啟檔案

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.