Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/silentcloud/react-native-clipboard
React Native component for getting or setting clipboard content
https://github.com/silentcloud/react-native-clipboard
Last synced: 5 days ago
JSON representation
React Native component for getting or setting clipboard content
- Host: GitHub
- URL: https://github.com/silentcloud/react-native-clipboard
- Owner: silentcloud
- License: mit
- Created: 2015-07-16T08:15:23.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-07T08:49:21.000Z (almost 9 years ago)
- Last Synced: 2024-11-11T20:51:54.026Z (about 1 month ago)
- Language: Java
- Size: 92.8 KB
- Stars: 66
- Watchers: 4
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-react-native - react-native-clipboard ★58 - React Native component for getting or setting clipboard content (Components / System)
- awesome-react-native - react-native-clipboard ★58 - React Native component for getting or setting clipboard content (Components / System)
- awesome-react-native - react-native-clipboard ★58 - React Native component for getting or setting clipboard content (Components / System)
- awesome-react-native-ui - react-native-clipboard ★50 - React Native component for getting or setting clipboard content (Components / System)
- awesome-react-native - react-native-clipboard ★58 - React Native component for getting or setting clipboard content (Components / System)
README
**NOTE:**
Clipboard API has been part of RN core since version 0.17, [https://github.com/facebook/react-native/blob/master/Libraries/Components/Clipboard/Clipboard.js](https://github.com/facebook/react-native/blob/master/Libraries/Components/Clipboard/Clipboard.js), [#5](https://github.com/silentcloud/react-native-clipboard/issues/5). This project will not add any new features any more...
---# react-native-clipboard
React Native component for getting or setting clipboard content
## Usage
```javascript
npm install react-native-clipboard --save
```
## iOS
In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name], Go to node_modules ➜ react-native-clipboard and add the `RNClipboard.xcodeproj` fileIn XCode, in the project navigator, select your project. Add the lib*.a from the RNClipboard project to your project's Build Phases ➜ Link Binary With Libraries Click `RNClipboard.xcodeproj` file you added before in the project navigator and go the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic'). Look for Header Search Paths and make sure it contains both $(SRCROOT)/../react-native/React and $(SRCROOT)/../../React - mark both as recursive.
Run your project (Cmd+R)
## Android
* In `android/setting.gradle````gradle
...
include ':react-native-clipboard'
project(':react-native-clipboard').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-clipboard/RNClipboardAndroid/app')
```* In `android/app/build.gradle`
```gradle
...
dependencies {
...
compile project(':react-native-clipboard')
}
```* register module (in MainActivity.java)
```java
import com.davidsandor.rnclipboardandroid.RNClipboardAndroidPackage;; // <--- import
public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
......@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new RNClipboardAndroidPackage()) // <------ add here
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();mReactRootView.startReactApplication(mReactInstanceManager, "example", null);
setContentView(mReactRootView);
}......
}
```## Examples
```javascript
var Clipboard = require('react-native-clipboard');
Clipboard.get(content => {
console.log(content);
});Clipboard.set('abc');
```