1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | #import "RCTClipboard.h"
|
9 |
|
10 | #import <FBReactNativeSpec/FBReactNativeSpec.h>
|
11 | #import <UIKit/UIKit.h>
|
12 |
|
13 | #import "CoreModulesPlugins.h"
|
14 |
|
15 | using namespace facebook::react;
|
16 |
|
17 | @interface RCTClipboard () <NativeClipboardSpec>
|
18 | @end
|
19 |
|
20 | @implementation RCTClipboard
|
21 |
|
22 | RCT_EXPORT_MODULE()
|
23 |
|
24 | - (dispatch_queue_t)methodQueue
|
25 | {
|
26 | return dispatch_get_main_queue();
|
27 | }
|
28 |
|
29 |
|
30 | RCT_EXPORT_METHOD(setString:(NSString *)content)
|
31 | {
|
32 | UIPasteboard *clipboard = [UIPasteboard generalPasteboard];
|
33 | clipboard.string = (content ? : @"");
|
34 | }
|
35 |
|
36 | RCT_EXPORT_METHOD(getString:(RCTPromiseResolveBlock)resolve
|
37 | reject:(__unused RCTPromiseRejectBlock)reject)
|
38 | {
|
39 | UIPasteboard *clipboard = [UIPasteboard generalPasteboard];
|
40 | resolve((clipboard.string ? : @""));
|
41 | }
|
42 |
|
43 | - (std::shared_ptr<TurboModule>)getTurboModuleWithJsInvoker:(std::shared_ptr<CallInvoker>)jsInvoker
|
44 | {
|
45 | return std::make_shared<NativeClipboardSpecJSI>(self, jsInvoker);
|
46 | }
|
47 |
|
48 | @end
|
49 |
|
50 | Class RCTClipboardCls(void) {
|
51 | return RCTClipboard.class;
|
52 | }
|