├── RCTPasteBoard ├── PasteBoard.h └── PasteBoard.m ├── README.md ├── index.js └── package.json /RCTPasteBoard/PasteBoard.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "RCTBridgeModule.h" 4 | #import "RCTBridge.h" 5 | #import "RCTEventDispatcher.h" 6 | 7 | @interface PasteBoard : UIView 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /RCTPasteBoard/PasteBoard.m: -------------------------------------------------------------------------------- 1 | #import "RCTBridgeModule.h" 2 | #import "PasteBoard.h" 3 | 4 | @implementation PasteBoard 5 | 6 | RCT_EXPORT_MODULE(); 7 | 8 | RCT_EXPORT_METHOD(copyText:(NSString *)input callback:(RCTResponseSenderBlock)callback) 9 | { 10 | 11 | UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; 12 | pasteboard.string = input; 13 | 14 | callback(@[input]); 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## react-native-pasteboard 2 | Copy text to your clipboard 3 | 4 | **Update** 5 | This is now supported out of the box in React-Native. You no longer need this module. I'll leave it up here just for history :) 6 | 7 | ### Add it to your project 8 | 9 | 1. Run `npm install react-native-pasteboard --save` 10 | 2. Open your project in XCode, right click on your project and click `Add Files to "Your Project Name"` 11 | 3. Add `RCTPasteBoard` from your `node_modules/react-native-pasteboard` folder. 12 | 4. Whenever you want to use it within React Native code now you can: 13 | `var PasteBoard = require('react-native-pasteboard');` 14 | 15 | 16 | ## Usage 17 | 18 | ```javascript 19 | var PasteBoard = require('react-native-pasteboard'); 20 | 21 | PasteBoard.copyText('Hello world!' , (callback) => { 22 | AlertIOS.alert('Alert', 'Link copied to clipboard!'); 23 | }); 24 | ``` 25 | 26 | ## Functions 27 | 28 | `copyText(input, callback)` 29 | 30 | Callback is required. 31 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const PasteBoard = require('react-native').NativeModules.PasteBoard; 2 | module.exports = { 3 | copyText(input, callback) { 4 | PasteBoard.copyText(input, callback); 5 | } 6 | }; 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-pasteboard", 3 | "version": "1.3.0", 4 | "description": "Copy text to clipboard", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [ 10 | "react-component", 11 | "react-native", 12 | "ios", 13 | "clipboard" 14 | ], 15 | "peerDependencies": { 16 | "react-native": ">=0.5" 17 | }, 18 | "author": "Yamill Vallecillo (github.com/yamill)", 19 | "license": "ISC", 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/yamill/react-native-pasteboard.git" 23 | }, 24 | "bugs": { 25 | "url": "https://github.com/yamill/react-native-pasteboard/issues" 26 | }, 27 | "homepage": "https://github.com/yamill/react-native-pasteboard#readme" 28 | } 29 | --------------------------------------------------------------------------------