iOS 上的 DropBox 应用程序有 URL 方案吗?

发布于 2025-01-08 11:00:44 字数 234 浏览 0 评论 0原文

我希望能够在我的应用程序中启动 DropBox 应用程序。因此我想知道 DropBox 应用程序是否有一个可以用来调用 openURL 的 URL 方案,类似这样,但我不知道这个字符串应该是什么。

NSURL *myURL = [NSURL URLWithString:@"dropbox://"];
[[UIApplication sharedApplication] openURL:myURL];

I would like to be able to launch the DropBox app within my app. Therefore I would like to know if the DropBox app has a URL scheme that I can use to call openURL, something like this, except I don't know what this string should be.

NSURL *myURL = [NSURL URLWithString:@"dropbox://"];
[[UIApplication sharedApplication] openURL:myURL];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

懷念過去 2025-01-15 11:00:44

您可以使用 Dropbox url-scheme 做的唯一事情就是将您的 Dropbox 应用程序连接到它。
像这样:

var key = "[YOUR API KEY]";
var secret = "[YOUR API SECRET]";
var apiversion = "1";

window.open("dbapi-1://"+apiversion+"/connect?k="+key+"&s="+secret);

通常,dropbox-app 通过使用以下方案打开您的 iOS 应用程序进行响应:

db-[YOU API KEY]://connect?oauth_token=SOMETOKEN&oauth_token_secret=SOMEOATHTOKEN&uid=SOMETHING

或通过

db-[YOU API KEY]://cancel

查看 Dropbox SDK for iOS 得到这个。

The only thing you can do with the Dropbox url-scheme is connect your Dropbox App to it.
Like this:

var key = "[YOUR API KEY]";
var secret = "[YOUR API SECRET]";
var apiversion = "1";

window.open("dbapi-1://"+apiversion+"/connect?k="+key+"&s="+secret);

Normally the dropbox-app responses by opening your iOS app with the following scheme:

db-[YOU API KEY]://connect?oauth_token=SOMETOKEN&oauth_token_secret=SOMEOATHTOKEN&uid=SOMETHING

or with:

db-[YOU API KEY]://cancel

Got this from looking at the Dropbox SDK for iOS.

梅倚清风 2025-01-15 11:00:44

Dropbox 的 URL 方案是

dbapi-1://

Dropbox's URL scheme is

dbapi-1://
耳根太软 2025-01-15 11:00:44

如果您需要在 iOS Dropbox 应用中打开特定文件,可以使用以下技巧:

  1. 对 URL 进行编码。
  2. 将编码的 URL 附加到 dbapi-6://1/viewLink?url= 前缀。

注意:这没有记录,并且可能在未来的版本中更改。

整个代码应该如下所示:

// `yourURLString` is the URL string you want to open 

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"dbapi-6://"]) 
{    
    NSString *encodedFileURLString =
        [yourURLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    NSString *fullURLString = 
        [@"dbapi-6://1/viewLink?url=" stringByAppendingString:encodedFileURLString];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:fullURLString]];
}
else
{
    // Otherwise open Safari
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:yourURLString]];
}

If you need to open a specific file in the iOS Dropbox app, you can use this trick:

  1. Encode your URL.
  2. Append encoded URL to the dbapi-6://1/viewLink?url= prefix.

Attention: this is not documented and may change in future releases.

The whole code should look like this:

// `yourURLString` is the URL string you want to open 

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"dbapi-6://"]) 
{    
    NSString *encodedFileURLString =
        [yourURLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    NSString *fullURLString = 
        [@"dbapi-6://1/viewLink?url=" stringByAppendingString:encodedFileURLString];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:fullURLString]];
}
else
{
    // Otherwise open Safari
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:yourURLString]];
}
暖树树初阳… 2025-01-15 11:00:44

Dropbox 没有 URL 方案。不过,您可以通过 UIDocumentInteractionController 与 Dropbox 交互。您可以阅读有关 这里。我见过一些允许您在 Dropbox 中打开文件的应用程序,我想这就是实现的方法。

Dropbox does not have a URL scheme. However, you can interact with Dropbox via UIDocumentInteractionController. You can read about that here. I've seen a few apps that allow you to open files in Dropbox, and I assume this is how that's done.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文