Does the DropBox app on iOS have a URL scheme?

安稳与你 提交于 2019-12-18 05:04:12

问题


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

回答1:


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.




回答2:


Dropbox's URL scheme is

dbapi-1://



回答3:


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]];
}



回答4:


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.



来源:https://stackoverflow.com/questions/9406546/does-the-dropbox-app-on-ios-have-a-url-scheme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!