RCTClipboard.m 760 B

1234567891011121314151617181920212223242526272829303132333435
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import "RCTClipboard.h"
  8. #import <UIKit/UIKit.h>
  9. @implementation RCTClipboard
  10. RCT_EXPORT_MODULE()
  11. - (dispatch_queue_t)methodQueue
  12. {
  13. return dispatch_get_main_queue();
  14. }
  15. RCT_EXPORT_METHOD(setString:(NSString *)content)
  16. {
  17. UIPasteboard *clipboard = [UIPasteboard generalPasteboard];
  18. clipboard.string = (content ? : @"");
  19. }
  20. RCT_EXPORT_METHOD(getString:(RCTPromiseResolveBlock)resolve
  21. rejecter:(__unused RCTPromiseRejectBlock)reject)
  22. {
  23. UIPasteboard *clipboard = [UIPasteboard generalPasteboard];
  24. resolve((clipboard.string ? : @""));
  25. }
  26. @end