ios - 在 React Native (IOS) 的 PowerPoint 应用程序中打开一个 .ppt 文件
问题描述
我知道我可以使用import {Linking} from 'react-native'
以使用Linking.canOpenURL(url)
和打开另一个应用程序。
我可以通过这样做打开PowerPointLinking.canOpenURL('ms-powerpoint://app')
:但我需要在那里打开一个文件。
根据微软的文档,我应该能够做到这一点:
Linking.canOpenURL('ms-powerpoint:ofv|u|https://blablabla.com/file.pptx')
但应用程序告诉我:
"抱歉,file.pptx 存储在不受支持的服务器位置。 "
我想的另一件事是首先下载文件并发送本地路径,但是,虽然它打开 PowerPoint 并显示“下载/打开”消息,但它显示的好像是一个空白会话。
这是一小段代码:
import React from 'react';
import {Button, Linking} from 'react-native';
import RNFS, {DownloadFileOptions} from 'react-native-fs';
function ShowPPTComponent(props) {
function openFile() {
const {file} = props;
const temporalStoragePath = `${RNFS.DocumentDirectoryPath}/${file.name}.${file.extension}`;
const options = {
fromUrl: file.url,
toFile: temporalStoragePath,
};
// Downloads the file.
RNFS.downloadFile(options as DownloadFileOptions).promise.then(() => {
const url = `ms-powerpoint:ofv|u|${temporalStoragePath}`;
// Goes to PowerPoint
return Linking.openURL(url);
});
}
return (
<Button onPress={openFile} title="Open in PowerPoint" />
);
}
信息清单
<key>LSApplicationQueriesSchemes</key>
<array>
<string>launch-ppt</string>
<string>powerpoint</string>
<string>ms-powerpoint</string>
<string>open-ppt</string>
</array>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UIFileSharingEnabled</key>
<true/>
<key>UISupportsDocumentBrowser</key>
<true/>
笔记:
在应用程序的另一个地方,我显示了 IOS 共享选项,我能够选择 PowerPoint 并打开文件,它运行良好。所以文件和 PowerPoint 应用程序都做得很好。
(这里的想法是不显示 IOS 共享模式,而是直接用文件打开 PowerPoint)。
提前致谢 !
解决方案
推荐阅读
- r - 根据不同列中的其他 id 生成新的 id 列
- azure - 使用 Azure 逻辑应用从 Salesforce 获取记录
- amazon-web-services - AWS 命令行查询 EC2 描述可用的网络接口
- javascript - 在移动设备上,我希望在单击 ID 时关闭导航栏
- java - JAVA:如何存储登录用户
- python - 如何使用 python-docx 使文本变为粗体、蓝色、16 号和特定字体?
- node.js - Nock 标头 - 错误:Nock:与请求不匹配
- python - 我可以在多行 f 字符串中期望什么行尾
- jestjs - 当模拟类依赖于 SUT 时,如何更改不同测试的 jest.mock 值?
- ubuntu - openssh 无法创建目录 /home/local/
/.ssh