Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tinycreative/react-native-dropbox-chooser
https://github.com/tinycreative/react-native-dropbox-chooser
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/tinycreative/react-native-dropbox-chooser
- Owner: tinycreative
- Created: 2015-11-13T15:34:30.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-04T16:34:06.000Z (almost 7 years ago)
- Last Synced: 2024-11-09T03:49:02.319Z (about 1 month ago)
- Language: Objective-C
- Size: 1000 KB
- Stars: 23
- Watchers: 6
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
- awesome-react-native - react-native-dropbox-chooser ★21 - React Native dropbox chooser module (Components / UI)
- awesome-react-native - react-native-dropbox-chooser ★21 - React Native dropbox chooser module (Components / UI)
- awesome-react-native - react-native-dropbox-chooser ★21 - React Native dropbox chooser module (Components / UI)
- awesome-react-native - react-native-dropbox-chooser ★21 - React Native dropbox chooser module (Components / UI)
- awesome-react-native-ui - react-native-dropbox-chooser ★16 - React Native dropbox chooser module (Components / UI)
README
# react-native-dropbox-chooser
## What is this?
For more details check out [https://www.dropbox.com/developers/chooser#ios](https://www.dropbox.com/developers/chooser#ios) for an explanation.
## Only Works On Device
This will only work on Device. This will open up a window prompting you to install the Dropbox app on the Simulator.
## Install
`npm install react-native-dropbox-chooser --save`
## Sign up
You'll need to sign up and get an app key from Dropbox.
First go here [https://www.dropbox.com/developers/apps/create](https://www.dropbox.com/developers/apps/create).
* Select "Dropbox API"
* Select what you need access to
* Name your app
* Agree to TOS
* SubmitYou'll see a section where it says "App key" and a series of numbers/letters. We'll need this in a second.
## Setup
First off add it to your project. How to link native modules can be found here. [http://facebook.github.io/react-native/docs/linking-libraries-ios.html#content](http://facebook.github.io/react-native/docs/linking-libraries-ios.html#content).
This will use LinkingIOS so we'll need to add this code to your `AppDelegate.m`
At the top of the file you will need to add `#import "RCTLinkingManager.h"`
Should look like
```
#import "AppDelegate.h"#import "RCTRootView.h"
#import "RCTLinkingManager.h"
```Then before the `@end` you need to add this code.
```
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [RCTLinkingManager application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}
```
Explanation can be found here [https://facebook.github.io/react-native/docs/linkingios.html#content](https://facebook.github.io/react-native/docs/linkingios.html#content).This will now start complaining that `RCTLinkingManager` doesn't exist.
We'll need to add header search paths for the Libraries.
Go to `Build Settings`, find `Header Search Paths`, and add `$(SRCROOT)/../node_modules/react-native/Libraries`. Set it to `recursive`.Because we are using the chooser we'll need to add the below configuration to the `Info.plist`
What this will allow us to do is throw over the the Dropbox app and have it send us the links back.```
LSApplicationQueriesSchemesdbapi-1
dbapi-3```
Now go to the `Info` tab.
At the bottom it will have a section called `URL Types`.
Open it and press the `+`.Add `db-APPKEYHERE` into the `URL Schemes` input box.
## How to use
Require the module.
```
var DropboxClient = require('react-native-dropbox-chooser');
``````
componentDidMount() {
DropboxClient.init({
appId: 'YOURAPPIDHERE',
onFiles: this.handleFiles //Callback that receives file(s) when they are selected
});
},componentWillUnmount() {
DropboxClient.remove(); //Don't forge to remove it
},
```## Done
We should be good to go!