Giter Site home page Giter Site logo

react-native-clipboard / clipboard Goto Github PK

View Code? Open in Web Editor NEW
645.0 7.0 109.0 2.84 MB

React Native Clipboard API for both iOS and Android.

License: MIT License

Java 21.95% JavaScript 5.00% Objective-C 2.72% Ruby 3.46% Starlark 1.12% TypeScript 29.29% C++ 24.88% C 0.19% Objective-C++ 11.39%
react-native clipboard hacktoberfest

clipboard's Introduction

@react-native-clipboard/clipboard

Build Status Version Supports macOS, iOS, Android, and Windows MIT License Lean Core Badge

React Native Clipboard API for macOS, iOS, Android, and Windows.

macOS iOS Android Windows

Getting started

Install the library using either Yarn:

yarn add @react-native-clipboard/clipboard

or npm:

npm install --save @react-native-clipboard/clipboard

Link

React Native v0.60+

For iOS, use cocoapods to link the package.

run the following command:

$ npx pod-install

For android, the package will be linked automatically on build.

For React Native version 0.59 or older

React Native <= 0.59

run the following command to link the package:

$ react-native link @react-native-clipboard/clipboard

For iOS, make sure you install the pod file.

cd ios && pod install && cd ..

or you could follow the instructions to manually link the project

Upgrading to React Native 0.60+

New React Native comes with autolinking feature, which automatically links Native Modules in your project. In order to get it to work, make sure you unlink Clipboard first:

$ react-native unlink @react-native-clipboard/clipboard

Migrating from the core react-native module

This module was created when the Clipboard API was split out from the core of React Native. To migrate to this module you need to follow the installation instructions above and then change you imports from:

import {Clipboard} from 'react-native';

to:

import Clipboard from '@react-native-clipboard/clipboard';

Example

import React, {useState} from 'react';
import {
  SafeAreaView,
  View,
  Text,
  TouchableOpacity,
  StyleSheet,
} from 'react-native';
import Clipboard from '@react-native-clipboard/clipboard';

const App = () => {
  const [copiedText, setCopiedText] = useState('');

  const copyToClipboard = () => {
    Clipboard.setString('hello world');
  };

  const fetchCopiedText = async () => {
    const text = await Clipboard.getString();
    setCopiedText(text);
  };

  return (
    <SafeAreaView style={{flex: 1}}>
      <View style={styles.container}>
        <TouchableOpacity onPress={copyToClipboard}>
          <Text>Click here to copy to Clipboard</Text>
        </TouchableOpacity>
        <TouchableOpacity onPress={fetchCopiedText}>
          <Text>View copied text</Text>
        </TouchableOpacity>

        <Text style={styles.copiedText}>{copiedText}</Text>
      </View>
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  copiedText: {
    marginTop: 10,
    color: 'red',
  },
});

export default App;

Reference

Methods

Clipboard

getString()

static getString()

Get content of string type, this method returns a Promise, so you can use following code to get clipboard content

async _getContent() {
  var content = await Clipboard.getString();
}

getStrings()

static getStrings()

(iOS only) Get contents of string array type, this method returns a Promise, so you can use following code to get clipboard content

async _getContent() {
  var content = await Clipboard.getStrings();
}

setString()

static setString(content)

Set content of string type. You can use following code to set clipboard content

_setContent() {
  Clipboard.setString('hello world');
}

Parameters

Name Type Required Description
content string Yes The content to be stored in the clipboard

setStrings()

static setStrings(content)

(iOS only) Set content of string array type. You can use following code to set clipboard content

_setContent() {
  Clipboard.setStrings(['hello world', 'second string']);
}

Parameters

Name Type Required Description
content string[] Yes The content to be stored in the clipboard

hasString()

static hasString()

Returns whether the clipboard has content or is empty. Can check if there is a content in clipboard without triggering PasteBoard notification for iOS 14+

hasURL()

static hasURL()

(iOS only) Returns whether the clipboard has a URL content. Can check if there is a URL content in clipboard without triggering PasteBoard notification for iOS 14+

hasNumber()

static hasNumber()

(iOS 14+ only) Returns whether the clipboard has a Number(UIPasteboardDetectionPatternNumber) content. Can check if there is a Number content in clipboard without triggering PasteBoard notification for iOS 14+

hasWebURL()

static hasWebURL()

(iOS 14+ only) Returns whether the clipboard has a WebURL(UIPasteboardDetectionPatternProbableWebURL) content. Can check if there is a WebURL content in clipboard without triggering PasteBoard notification for iOS 14+

useClipboard

useClipboard is a utility hooks for the Clipboard module. data contains the content stored in the clipboard.

import React, {useEffect} from 'react';
import {Text} from 'react-native';
import {useClipboard} from '@react-native-clipboard/clipboard';

export const HooksSample = () => {
  const [data, setString] = useClipboard();

  useEffect(() => {
    setString('hello world');
  }, []);

  return <Text>{data}</Text>;
};

getImage()

static getImage()

Get content of image in base64 string type, this method returns a Promise, so you can use following code to get clipboard content (ANDROID only)

async _getContent() {
  var content = await Clipboard.getImage();
}

Mocking Clipboard

If you're using jest as a test runner, you will need to setup a mock for clipboard, as NativeModules will be undefined when testing with Jest.

Create a jest.setup.js in your project root,and set up the following to have Clipboard mocked:

import mockClipboard from '@react-native-clipboard/clipboard/jest/clipboard-mock.js';

jest.mock('@react-native-clipboard/clipboard', () => mockClipboard);

Maintainers

Contributing

Please see the contributing guide.

License

The library is released under the MIT licence. For more information see LICENSE.

clipboard's People

Contributors

alanleedev avatar alexhernandez avatar amgleitman avatar asklar avatar atulsmadhugiri avatar brendonsled avatar chiaramooney avatar chrisglein avatar cmcaboy avatar cristianoccazinsp avatar dependabot[bot] avatar djkazic avatar dulmandakh avatar evanbacon avatar fetten avatar gabrieldonadel avatar giannismacheras avatar gnardini avatar harisbaig100 avatar helenaford avatar ilyalesik avatar itsjgf avatar j-piasecki avatar lunziyuan avatar malcolmtomisin avatar naturalclar avatar outofmemory avatar saadnajmi avatar taboulot avatar tatianakapos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

clipboard's Issues

Paste not possible on iOS 15.5 simulator on M1

Environment

System:
    OS: macOS 12.5.1
    CPU: (10) x64 Apple M1 Max
    Memory: 70.98 MB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.19 - ~/projects/release/app/node_modules/.bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
    Watchman: 2022.03.21.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /Users/xxx/.gem/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK:
      API Levels: 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
      Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0, 30.0.1, 30.0.2
      System Images: android-22 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom, android-24 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google ARM64-V8a Play ARM 64 v8a, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play ARM 64 v8a, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play ARM 64 v8a, android-31 | Google Play ARM 64 v8a, android-32 | Google Play ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.2 AI-212.5712.43.2112.8512546
    Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
  Languages:
    Java: javac 18 - /usr/local/opt/openjdk/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.66.3 => 0.66.3 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Platforms

iOS

Versions

  • iOS: 15.5

Description

Pasting text on the simulator displays the toast that the app requested clipboard text but no text is ever pasted. Neither via context menu nor programmatically.
Other non-react-native apps have no problem pasting the same text.

This seems related flutter/flutter#74970

null is not an object (evaluating 'u.default.setString')

Getting error null is not an object (evaluating 'u.default.setString') on using sample code in expo

No matter what I try, I'm getting the above error on trying to call the setString method via Clipboard.setString(). The same error appears on running the sample code in snack.expo

Here is the exact code that I used in expo:

import React, { useState } from 'react'
import { SafeAreaView, View, Text, TouchableOpacity, StyleSheet } from 'react-native'
import Clipboard from '@react-native-community/clipboard'

export default function App() {
  const [copiedText, setCopiedText] = useState('')

  const copyToClipboard = () => {
    Clipboard.setString('hello world')
  }

  const fetchCopiedText = async () => {
    const text = await Clipboard.getString()
    setCopiedText(text)
  }

  return (
    <SafeAreaView style={{ flex: 1 }}>
      <View style={styles.container}>
        <TouchableOpacity onPress={() => copyToClipboard()}>
          <Text>Click here to copy to Clipboard</Text>
        </TouchableOpacity>
        <TouchableOpacity onPress={() => fetchCopiedText()}>
          <Text>View copied text</Text>
        </TouchableOpacity>

        <Text style={styles.copiedText}>{copiedText}</Text>
      </View>

    </SafeAreaView>
  )
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  copiedText: {
    marginTop: 10,
    color: 'red'
  }
})

Thanks ahead!

Execution failed for task ':react-native-clipboard_clipboard:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details.

Environment

Platforms

Versions

  • Android:
  • iOS:
  • react-native-netinfo:
  • react-native:
  • react:

Description

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Note: /Users/extended/Downloads/vibesocialmusic-82830-react-native copy/src/node_modules/@invertase/react-native-apple-authentication/android/src/main/java/com/RNAppleAuthentication/AppleAuthenticationAndroidModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/extended/Downloads/vibesocialmusic-82830-react-native copy/src/node_modules/react-native-android-location-enabler/android/src/main/java/com/heanoria/library/reactnative/locationenabler/RNAndroidLocationEnablerModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/Users/extended/Downloads/vibesocialmusic-82830-react-native copy/src/node_modules/@react-native-clipboard/clipboard/android/src/main/java/com/reactnativecommunity/clipboard/ClipboardModule.java:136: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R){
^
symbol: variable R
location: class VERSION_CODES
/Users/extended/Downloads/vibesocialmusic-82830-react-native copy/src/node_modules/@react-native-clipboard/clipboard/android/src/main/java/com/reactnativecommunity/clipboard/ClipboardModule.java:137: error: cannot find symbol
bitmap.compress(Bitmap.CompressFormat.WEBP_LOSSLESS, 100, outputStream);
^
symbol: variable WEBP_LOSSLESS
location: class CompressFormat
Note: /Users/extended/Downloads/vibesocialmusic-82830-react-native copy/src/node_modules/@react-native-clipboard/clipboard/android/src/main/java/com/reactnativecommunity/clipboard/ClipboardModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors

Reproducible Demo

how to hide clipboard toast message??

i wanna show toast message when i succeed copy.
but i think that failed showing toast message when i copied in android 11 device.

how to hide clipboard toast message?
or how to show toast message in android 11 device?

Clipboard use notification in iOS 14

Environment

System:
OS: macOS 10.15.5
CPU: (4) x64 Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
Memory: 207.46 MB / 10.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 14.3.0 - /usr/local/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.14.5 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 23, 25, 26, 27, 28
Build Tools: 23.0.1, 25.0.3, 26.0.1, 26.0.3, 27.0.0, 27.0.3, 28.0.0, 28.0.3
System Images: android-28 | Google Play Intel x86 Atom, android-R | Google APIs Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5692245
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_171 - /usr/bin/javac
Python: 2.7.15 - /usr/local/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
react-native: Not Found

Platforms

iOS 14

Versions

  • Android:
  • iOS: 14
  • react-native-netinfo:
  • react-native: 0.62.2
  • react: 16.11.0

Description

On app start, I have this message in new iOS, but my app read nothing from clipboard. Only uses clipboard in some places of the app to save text.
image

Reproducible Demo

Install library

hasImage method not working with HEIC images

Environment

System:
    OS: macOS 12.3.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 225.18 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
    Watchman: 2021.11.08.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK:
      API Levels: 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 30.0.0, 30.0.2, 31.0.0
      System Images: android-26 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-31 | Google APIs Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.7042882
    Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_265 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1
    react-native: 0.64.3 => 0.64.3
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Platforms

both

Apple not approve application

Environment

System:
OS: macOS 12.4
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Memory: 37.11 MB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
Yarn: 1.22.18 - /usr/local/bin/yarn
npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK: Not Found
IDEs:
Android Studio: 2021.1 AI-211.7628.21.2111.8193401
Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild
Languages:
Java: 11.0.11 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.66.0 => 0.66.0
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Platforms

iOS

Description

Hi everyone! Recently, we tried to replace the old and deprecated RN Clipboard library with yours, but Apple rejected our applications. When we reverse just this change it's OK and approved, otherwise we can't use your library. Do you have any chance to check it? I'll share Apple's response with you; I hope it'll be helpful. Farewell!

Dear Developer,

We identified one or more issues with a recent delivery for your app. Please correct the following issues, then upload again.

ITMS-90338: Non-public API usage - The app references non-public selectors in InstantPickerApp: estimatedProgress, initWithFrame:configuration:, isMainFrame, navigationType, newSocketQueueForConnectionFromAddress:onSocket:, onSuccess:, setNavigationDelegate:, setProcessPool:, socket:didAcceptNewSocket:, socket:didConnectToHost:port:, socket:didConnectToUrl:, socket:didReadData:withTag:, socket:didReadPartialDataOfLength:tag:, socket:didReceiveTrust:completionHandler:, socket:didWriteDataWithTag:, socket:didWritePartialDataOfLength:tag:, socket:shouldTimeoutReadWithTag:elapsed:bytesDone:, socket:shouldTimeoutWriteWithTag:elapsed:bytesDone:, socketDidCloseReadStream:, socketDidDisconnect:withError:, socketDidSecure:, targetFrame, userContentController, websiteDataStore. If method names in your source code match the private Apple APIs listed above, altering your method names will help prevent this app from being flagged in future submissions. In addition, note that one or more of the above APIs may be located in a static library that was included with your app. If so, they must be removed. For further information, visit the Technical Support Information at https://clicktime.symantec.com/3B5NFMBRDMdcEyHtR48XbX47GS?u=http%3A%2F%2Fdeveloper.apple.com%2Fsupport%2Ftechnical%2F

No account for team "FKLQTR48YQ"

Environment

Platforms

iOS

Versions

  • Android:
  • iOS:
  • react-native-netinfo:
  • react-native:
  • react:

Description

Reproducible Demo

Build error on iOS:
No account for team "FKLQTR48YQ". (Add a new account in the Accounts preference pane or verify that your accounts have valid credentials.)

setString doesn't work

Environment

 Expo CLI 3.27.4 environment info:
    System:
      OS: Windows 10 10.0.20206
    Binaries:
      Node: 14.10.1 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.19.2 - F:\Programy\yarm\bin\yarn.CMD
      npm: 6.14.5 - C:\Program Files\nodejs\npm.CMD
    npmPackages:
      expo: ^38.0.10 => 38.0.10
      react: ^16.11.0 => 16.11.0
      react-dom: ^16.11.0 => 16.11.0
      react-native: https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz => 0.62.2
      react-native-web: ^0.11.7 => 0.11.7
    Expo Workflow: managed

Platforms

iOS, not sure about Android, it is possibly (and probably) also affected.

Versions

  • iOS: 14 beta 7
  • react-native: 0.62
  • react: 16.11.0

Description

When trying to set a string to the clipboard, it is denied and errors out:

TypeError: null is not an object (evaluating 'NativeClipboard_1.setString')

Reproducible Demo

Clipboard.setString("Test"); // Errors out

IOS is still error

Build/Products/Debug-iphonesimulator/react-native-clipboard/libreact-native-clipboard.a(RCTClipboard.o)
ld: 2 duplicate symbols for architecture x86_64

nom install is still not right

require 'json'

package = JSON.parse(File.read(File.join(dir, 'package.json')))

Pod::Spec.new do |s|
s.name = "react-native-clipboard"
s.version = package['version']
s.summary = package['description']
s.license = package['license']

s.authors = package['author']
s.homepage = package['homepage']
s.platform = :ios, "9.0"

s.source = { :git => "https://github.com/react-native-community/react-native-clipboard", :tag => "#{s.version}" }
s.source_files = "ios/**/*.{h,m}"

s.dependency 'React'
end

Check clipboard / pasteboard type [iOS]

Describe the Feature

During WWDC 2020, Apple announced a feature in iOS 14, which alerts the user, if an app reads from the clipboard. This has caused a lot of problems and bad PR since, so I would suggest we implement the contains(pasteboard) API here.

It basically just checks the clipboard for a type of data, without that pesky notification.

9to5Mac article

Possible Implementations

The hardest thing about this would be the port, we could name the functions similarly.

E.g.:

Clipboard.hasURL() // => bool
Clipboard.hasText() // => bool

or

Clipboard.contains(String) // where String is one of the types

Related Issues

#56

Edit:

Clipboard.hasString() has been implemented in #73
Clipboard.hasURL() has been implemented in #78

Waiting for

  • Clipboard.hasBool()
  • Clipboard.hasImage()?

build.gradle file is missing.

Environment

Environment:
OS: macOS 10.14.5
Node: 11.9.0
Yarn: 1.13.0
npm: 6.9.0
Watchman: 4.9.0
Xcode: Xcode 10.2.1 Build version 10E1001
Android Studio: 3.4 AI-183.6156.11.34.5692245

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.4 => 0.55.4

Platforms

Android

Description

I found that build.gradle file is missing, so the gradle sync failed.

Update typescript definitions for static hasURL() method

Describe the Feature

Update the hasURL typescript definitions for the library. It currently looks like this (pretty much the same as hasString's), giving wrong in-editor documentation to users.
Screen Shot 2021-05-25 at 19 14 30

Possible Implementations

Add the relevant example to the definitions file. Extracting from the readme:

  /**
     * (IOS Only)
     * Returns whether the clipboard has a URL content. Can check
     * if there is a URL content in clipboard without triggering PasteBoard notification for iOS 14+
     * This method returns a `Promise`, so you can use following code to check for url content in clipboard.
     * ```javascript
     * async _hasContent() {
     *   var hasContent = await Clipboard.hasURL();
     * }
     * ```
     */

Related Issues

macOS support assignable pasteboard types

add an option for pasteboard types example:
@"org.nspasteboard.ConcealedType"

http://nspasteboard.org/

RCT_EXPORT_METHOD(setString:(NSString *)content setType: (NSString *)pasteboardtype
{
  NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
  [pasteboard clearContents];
  [pasteboard setString:(content ? : @"") forType:pasteboardType];
}

Allows for clipboard history apps to ignore concealed or transient text.

Build failed on android react native clipboard ^1.8.5 cannot find symbol if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)

Environment

System:
OS: macOS 11.6
CPU: (8) arm64 Apple M1
Memory: 338.73 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 18.3.0 - /opt/homebrew/bin/node
Yarn: 1.22.17 - /opt/homebrew/bin/yarn
npm: 8.11.0 - /opt/homebrew/bin/npm
Watchman: HEAD-51a3b89 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /Users/admin/.rvm/gems/ruby-2.7.4/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
Android SDK: Not Found
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7784292
Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
Languages:
Java: 11.0.11 - /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/javac
Python: 3.8.6 - /Users/admin/.pyenv/shims/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.63.2 => 0.63.2
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Platforms

Android

Versions

  • Android: ^1.8.5
  • iOS: ^1.8.5
  • react-native-netinfo: ^5.9.6
  • react-native: 0.63.2
  • react: 16.13.1

Description

Today i was building my debug app on android as usual but i got this:
image

i tried: running./gradlew clean and upgrading the library but didnt help
Any suggestions?
Thanks

Fatal Exception: ClipboardModule.java line 9

Screenshot 2020-06-23 at 14 33 17

Environment

System:
OS: macOS 10.15.5
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 234.47 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 13.14.0 - ~/.nvm/versions/node/v13.14.0/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v13.14.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 23, 24, 25, 27, 28, 29
Build Tools: 28.0.3, 29.0.1, 29.0.2
System Images: android-16 | Google APIs Intel x86 Atom, android-22 | Google APIs ARM EABI v7a, android-22 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom
Android NDK: 17.2.4988734
IDEs:
Android Studio: Not Found
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_222 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
react-native: Not Found

Platforms

Android

Versions

Device
Brand: Realme
Model: realme C2
Orientation: Portrait
RAM free: 676.65 MB
Disk free: 10.74 GB

Operating System
Version: 9
Orientation: Portrait
Rooted: No

Description

last version

"@react-native-community/clipboard": "^1.2.2",

Got error from Crashlytics

ClipboardModule.java line 9
com.reactnativecommunity.clipboard.ClipboardModule.setString

Fatal Exception: java.lang.SecurityException
com.mbmobile from uid 10184 not allowed to perform READ_CLIPBOARD
com.reactnativecommunity.clipboard.ClipboardModule.setString

Clipboard.hasString() does not work on iOS16

Platforms

iOS

Versions

  • iOS: 16

Description

iOS16 is introducing a new privacy feature where users will need to grant access to their clipboard before an app can access it.

Even after granting access, Clipboard.hasString() returns blank.

Reproducible Demo

Test the sample project in a simulator on iOS16

Clipboard is null

Environment

React Native with Expo 39

Platforms

Android

Versions

  • Android: 10
  • react-native: 63

Description

...

import Clipboard from '@react-native-community/clipboard';

...

const Component = () => {

  useEffect(() => {
    const check = async () => {
      const clipboard = await Clipboard.getString();
      if (clipboard) {
        setClipboard(clipboard);
        Clipboard.setString('');
    };
    check();
  }, []);

...

This code throws this error: null is not an object (evaluating 'NativeClipboard_1.default.getString')

But strangely, when I test the code with Jest it works... Maybe Clipboard is not yet mounted properly when the effect is triggered.

hasString() always returns true even if clipboard is empty?

Environment

System:
    OS: macOS 12.0.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 173.00 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.12.0 - ~/.nvm/versions/node/v16.12.0/bin/node
    Yarn: 1.22.10 - ~/src/github.com/Shopify/arrive-client/node_modules/.bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.12.0/bin/npm
    Watchman: 2021.11.15.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.2 - /Users/barrymcgee/.gem/ruby/2.6.1/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
    Android SDK:
      API Levels: 29, 30
      Build Tools: 30.0.2
      System Images: android-30 | Google APIs Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.2 AI-202.7660.26.42.7486908
    Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.8 - /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.66.2 => 0.66.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Platforms

Both

Versions

  • Android: v12
  • iOS: v15
  • react-native-netinfo:
  • react-native:
  • react:

Description

When setting a conditional using await Clipboard.hasString(), I always get true returned regardless of whether my clipboard is empty or contains a string.

Note: To test an empty clipboard, I run pbcopy < /dev/null in my terminal.

Running jest tests fails tests

Environment

System:
OS: macOS 12.3
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 28.54 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.10.0 - /usr/local/bin/node
Yarn: 1.22.11 - /usr/local/bin/yarn
npm: 7.24.0 - /usr/local/bin/npm
Watchman: 2022.03.21.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.3 - /Users/REDACTED/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK:
API Levels: 27, 29, 30, 31
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0, 30.0.2, 31.0.0
System Images: android-27 | Intel x86 Atom, android-27 | Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 2021.1 AI-211.7628.21.2111.8193401
Xcode: 13.3/13E113 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_322 - /usr/bin/javac
npmPackages:
@react-native-community/cli: 5.0.1 => 5.0.1
react: 17.0.1 => 17.0.1
react-native: 0.64.2 => 0.64.2
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Platforms

Confirmed at least ios

Versions

  • Android: Not tested
  • iOS: 15.4
  • react-native-netinfo: 6.0.2
  • react-native: 64.2
  • react: 17.0.2

Description

I'm running the latest clipboard version: 1.10.0

Running jest tests results in this error for ALL the tests:

/Users/REDACTED/code/REDACTED/REDACTED/REDACTED/node_modules/@react-native-clipboard/clipboard/jest/clipboard-mock.js: Cannot find module '@jridgewell/gen-mapping'

java.lang.IllegalStateException: beginBroadcast() called while already in a broadcast

I don't think this is fixable (or maybe there's a way around it), but I'm just opening na issue here in case someone looks, and possible isolated on emulators only

Similar stuff I found over the internet: https://commonsware.com/blog/2013/08/08/developer-psa-please-fix-your-clipboard-handling.html

Platforms

Android

Versions

  • Android: API 29
  • react-native: 0.63.4

Description

java.lang.IllegalStateException: beginBroadcast() called while already in a broadcast

When triggering a copy, it crashes, and restarts the emulator (haven't tested on a physical device)

java.lang.IllegalStateException: beginBroadcast() called while already in a broadcast

*** FATAL EXCEPTION IN SYSTEM PROCESS: Thread-4
java.lang.IllegalStateException: beginBroadcast() called while already in a broadcast
	at android.os.RemoteCallbackList.beginBroadcast(RemoteCallbackList.java:241)
	at com.android.server.clipboard.ClipboardService.setPrimaryClipInternal(ClipboardService.java:583)
	at com.android.server.clipboard.ClipboardService$1.onHostClipboardUpdated(ClipboardService.java:205)
	at com.android.server.clipboard.HostClipboardMonitor.run(ClipboardService.java:125)
	at java.lang.Thread.run(Thread.java:919)

Reproducible Demo

Right now I can only reproduce it when I do Linking towards a browser or when react-native-inappbrowser-reborn is opened because it's the only paths I have available at the moment, but I feel like this happens when any activity other than react native's happen

  1. Keep calling setString(), they work as usual
  2. Go to a browser using Linking.open() or instantiate a browser using react-native-inappbrowser-reborn
  3. Go back to the app and try calling setString, and it should crash

This actually happens regardless if you do setString() first or not, it's always as long as you go to a browser and going back to the app, this also happens if you have a browser opened and attempted to call setString()

It doesn't crash if I go back to the app and close the browser from the multitask view (the square button)

Add hasPattern function

Describe the Feature

The Clipboard object has a general function hasString() but it is not enough. It is necessary it has a function like hasPattern that gets a pattern for example in Regular Expression format to check the clipboard content and return true or false. We could implement it on our code and I did it but since iOS 14 every time I get the string to check it with Requgalr Expression, iOS displays X pasted from Y message to the user because I have to get the string before checking.

Possible Implementations

I am not an iOS developer but I think Apple has a function for custom pattern checking in UIPasteboard.DetectionPattern and explains it here:

https://developer.apple.com/documentation/uikit/uipasteboard/detectionpattern/3622466-init

https://developer.apple.com/documentation/uikit/uipasteboard/detectionpattern

not able to install clipboard with react 7.14

Ask your Question

/node_modules/@react-native-community/clipboard/dist/NativeClipboard.js
Module not found: Can't resolve 'react-native' in 'C:\Workspace\sample\my-app\node_modules@react-native-community\clipboard\dist'

package.json

"dependencies": {
"@fluentui/react": "^7.149.2",
"@juggle/resize-observer": "^3.2.0",
"@react-native-community/clipboard": "1.5.0",
"axios": "^0.21.0",
"constate": "^3.1.0",
"core-js": "^3.6.5",
"es6-promise": "^4.2.8",
"oidc-client": "^1.10.1",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-query": "^2.25.2",
"react-query-devtools": "^2.6.1",
"react-router-dom": "^5.2.0",
"react-sortable-tree": "^2.2.0",
"react-sortable-tree-theme-file-explorer": "^2.0.0",
"react-use-measure": "^2.0.3",
"store": "^2.0.12"
},

"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@hot-loader/react-dom": "^17.0.0",
"@types/find-process": "1.2.0",
"@types/office-js": "^1.0.146",
"@types/office-runtime": "^1.0.17",
"@types/react": "^16.9.55",
"@types/react-dom": "^16.9.9",
"@types/react-hot-loader": "^4.1.1",
"@types/react-router-dom": "^5.1.6",
"@types/store": "^2.0.2",
"@types/webpack": "^4.41.24",
"@types/webpack-dev-server": "^3.11.1",
"babel-loader": "^8.1.0",
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^6.2.1",
"css-loader": "^5.0.0",
"eslint-config-office-addins": "^1.0.19",
"eslint-plugin-office-addins": "^0.1.7",
"eslint-plugin-react": "^7.21.5",
"file-loader": "^6.2.0",
"find-process": "^1.4.4",
"html-webpack-plugin": "^4.5.0",
"husky": "^4.3.0",
"mini-css-extract-plugin": "^1.2.1",
"office-addin-cli": "^1.0.13",
"office-addin-debugging": "^3.0.37",
"office-addin-dev-certs": "^1.5.7",
"office-addin-lint": "^1.0.27",
"office-addin-manifest": "1.5.9",
"pretty-quick": "^3.1.0",
"react-hot-loader": "^4.13.0",
"style-loader": "^2.0.0",
"ts-loader": "^8.0.7",
"tsconfig-paths-webpack-plugin": "^3.3.0",
"typescript": "^4.0.5",
"webpack": "^4.44.2",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0",
"@types/react-sortable-tree": "^0.3.12"
}

Error

[*] After install and import i got this below error.Why?

  • Unable to resolve "@react-native-clipboard/clipboard" from 'Demo.js'

Peer dependency warning

Environment

System:
    OS: Windows 10 10.0.18363
    CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
    Memory: 5.94 GB / 19.66 GB
  Binaries:
    Node: 12.16.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK:
      API Levels: 23, 24, 25, 26, 27, 28, 29
      Build Tools: 19.1.0, 20.0.0, 21.1.2, 22.0.1, 23.0.1, 23.0.2, 23.0.3, 24.0.0, 24.0.1, 24.0.2, 24.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.2, 27.0.3, 28.0.0, 28.0.1, 28.0.2, 28.0.3, 29.0.0, 29.0.1, 29.0.2
      System Images: android-21 | Google APIs Intel x86 Atom_64, android-22 | Intel x86 Atom_64, android-22 | Google APIs Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-24 | Google Play Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-26 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: Version  3.5.0.0 AI-191.8026.42.35.6010548
  Languages:
    Python: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0
    react-native: 0.62.1 => 0.62.1
  npmGlobalPackages:
    *react-native*: Not Found

Versions

  • @react-native-community/clipboard: 1.2.0
  • react-native: 0.62.1
  • react: 16.11.0

Description

npm WARN @react-native-community/[email protected] requires a peer of react@>=^16.0 but none is installed. You must install peer dependencies yourself.
npm WARN @react-native-community/[email protected] requires a peer of react-native@>=^0.57.0 but none is installed. You must install peer dependencies yourself.

Reproducible Demo

  1. npm install --save @react-native-community/clipboard

`npm install` is failing but `yarn` works.

There are no details to show. I am not able to install the package into other repo that usages NPM.

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> [email protected] postinstall /...............clipboard/node_modules/react-native-macos
> node scripts/postInstall.js


> @react-native-clipboard/[email protected] prepare /............./clipboard
> yarn build

yarn run v1.22.15
$ tsc
node_modules/@types/node/globals.d.ts:47:11 - error TS2300: Duplicate identifier 'AbortController'.

47 interface AbortController {
             ~~~~~~~~~~~~~~~

  node_modules/@types/react-native/globals.d.ts:389:15
    389 declare class AbortController {
                      ~~~~~~~~~~~~~~~
    'AbortController' was also declared here.

node_modules/@types/node/globals.d.ts:60:11 - error TS2300: Duplicate identifier 'AbortSignal'.

60 interface AbortSignal {
             ~~~~~~~~~~~

  node_modules/@types/react-native/globals.d.ts:376:15
    376 declare class AbortSignal {
                      ~~~~~~~~~~~
    'AbortSignal' was also declared here.

node_modules/@types/node/globals.d.ts:67:13 - error TS2300: Duplicate identifier 'AbortController'.

67 declare var AbortController: {
               ~~~~~~~~~~~~~~~

  node_modules/@types/react-native/globals.d.ts:389:15
    389 declare class AbortController {
                      ~~~~~~~~~~~~~~~
    'AbortController' was also declared here.

node_modules/@types/node/globals.d.ts:72:13 - error TS2300: Duplicate identifier 'AbortSignal'.

72 declare var AbortSignal: {
               ~~~~~~~~~~~

  node_modules/@types/react-native/globals.d.ts:376:15
    376 declare class AbortSignal {
                      ~~~~~~~~~~~
    'AbortSignal' was also declared here.

node_modules/@types/react-native/globals.d.ts:376:15 - error TS2300: Duplicate identifier 'AbortSignal'.

376 declare class AbortSignal {
                  ~~~~~~~~~~~

  node_modules/@types/node/globals.d.ts:60:11
    60 interface AbortSignal {
                 ~~~~~~~~~~~
    'AbortSignal' was also declared here.
  node_modules/@types/node/globals.d.ts:72:13
    72 declare var AbortSignal: {
                   ~~~~~~~~~~~
    and here.

node_modules/@types/react-native/globals.d.ts:389:15 - error TS2300: Duplicate identifier 'AbortController'.

389 declare class AbortController {
                  ~~~~~~~~~~~~~~~

  node_modules/@types/node/globals.d.ts:47:11
    47 interface AbortController {
                 ~~~~~~~~~~~~~~~
    'AbortController' was also declared here.
  node_modules/@types/node/globals.d.ts:67:13
    67 declare var AbortController: {
                   ~~~~~~~~~~~~~~~
    and here.


Found 6 errors.

Yarn can't find the package

Environment

yarn add @react-native-community/clipboard
yarn add v1.22.4
[1/4] ๐Ÿ”  Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@react-native-community%2fclipboard: Not found".
info If you think this is a bug, please open a bug report with the information provided in "/Users/anton/Documents/work/kme-mobile-app/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Platforms

Both

Versions

  • Android:
  • iOS:

Description

When i try add package in my project, yarn can't found the package.

Received warning asking to remove usages of `jcenter()` Maven repository from build scripts in RN 0.65.1

Ask your Question

Hi. I just upgraded React Native version 0.65.1 and having trouble to run the emulator.

This error appear, asking to remove jcenter() but this clipboard library still using jcenter(), right?

WARNING:: Please remove usages of 'jcenter()' Maven repository from your build scripts and migrate your build to other Maven repositories. This repository is deprecated and it will be shut down in the future. See http://developer.android.com/r/tools/jcenter-end-of-service for more information. Currently detected usages in: project ':react-native-clipboard_clipboard'

Does anyone having the same issue?
Any suggestion to overcome this issue?

Error upon Clipboard.setString

Ask your Question

I did npm install and pod install. Then I called Clip.setString. However, I'm getting this error:

Screen Shot 2020-08-05 at 10 36 13 PM

I'm not sure what this means. How do I solve this? Thanks!

Clipboard erased if deeplink into another app [iOS]

Platforms

iOS

Versions

  • iOS: iOS12 & 13
  • react-native: 60+

Description

Add something to clipboard. Deeplink into instagram-stories://, the clipboard contents are erased completely.

I feel like there's an explanation out there, probably from Apple, wondering what that might be.
Cheers!

getString() never resolves

Environment

info Fetching system and libraries information...
System:
    OS: macOS 12.0.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 2.66 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
    Watchman: 2021.12.20.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 23, 26, 27, 28, 29, 30, 31
      Build Tools: 28.0.3, 29.0.0, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 32.0.0
      System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-31 | Google APIs Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7583922
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_275 - /Users/xxx/.sdkman/candidates/java/current/bin/javac
    Python: 2.7.18 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: 6.1.0 => 6.1.0
    react: 17.0.2 => 17.0.2
    react-native: 0.65.1 => 0.65.1
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Platforms

both

Versions

Description

When I call await Clipboard.getString() the promise will not be resolved (ever)

This happens if your metro configuration is:

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
};

If you flip inlineRequires to false, then promise in this library starts working again. Because this is issue only with this package I believe there is some conflict, but for now I do not have deeper knowledge why is that, just reporting it here as it may help someone...

What is interesting though that this repository has the flag turned to true, I believe it will be issue just with "published / build" package.

There is similar issue opened in react-native repo: facebook/react-native#31558

Reproducible Demo

Android cannot get the clipboard content

Environment

react-native 0.63.3

Platforms

Android

Versions

  • Android:Android 10
  • iOS:
  • react-native-netinfo:
  • react-native:
  • react:

Description

cannot get the clipboard content when app Toggle front and back, only Kill the app, open again and get it

Reproducible Demo

Mock Clipboard Methods

I'm writing a unit tests for a project and when I write a test for a module which is dependent on this library, I got following error:

TypeError: Cannot read property 'setString' of undefined

Following is method to test

const onCopyPress = () => {
    Clipboard.setString(userData.publickey);

    ToastAndroid.show(t('createWallet.copiedToast'), ToastAndroid.SHORT);
};

Following is the calling point:

<TouchableOpacity testID={'copy'} onPress={() => onCopyPress()}>
        <Image source={clipboard} />
</TouchableOpacity>

Following is test for the above code:

const {getByTestId} = render(
      <Provider store={store}>
        <ThemeContextProvider>
          <Drawer {...props} theme={theme} />
        </ThemeContextProvider>
      </Provider>,
 );

let button = getByTestId('copy');

fireEvent.press(button);

try {
      expect(onCopyPress).toHaveBeenCalled();
} catch (e) {
      console.log('ee', e);
}

Native module RNCClipboard tried to override ClipboardModule

Environment

react-native run-android

Platforms

Android

Versions

  • Android: latest
  • iOS: latest
  • react-native-netinfo: no contain
  • react-native: 0.63.3
  • react: 16.13.1

Description

When I do the build to emulate the android, with the following command: react native run-android the cliboard library returns the error attached

Reproducible Demo

npx react-native run-android

image

NPM wrong versions?

Current latest version in github is 1.9.0, and it was in npm as well until recently. NPM is capped at 1.8.5 now, what's up?

@Naturalclar can you take a look? I can't tell whether or not 1.8.5 from npm has 1.9.0 fixes.

useClipboard causes TypeError

Environment

Expo CLI 4.0.17 environment info:
System:
OS: macOS 10.15.7
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.13.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.5 - /usr/local/bin/npm
IDEs:
Xcode: /undefined - /usr/bin/xcodebuild
npmPackages:
expo: ~40.0.0 => 40.0.0
react: 16.13.1 => 16.13.1
react-dom: 16.13.1 => 16.13.1
react-native: https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz => 0.63.2
react-native-web: ~0.13.12 => 0.13.18
Expo Workflow: managed

Platforms

MacOS web

Versions

Shown above

Description

Just using useClipboard() causes "TypeError: Cannot read property 'getString' of undefined".
FWIW, I'm also using TypeScript.

Reproducible Demo

import React, { useEffect } from 'react';
import { Text } from 'react-native';
import { useClipboard } from '@react-native-community/clipboard';

export default function App(): JSX.Element {
  const [clipboardText, setClipboardText] = useClipboard();

  useEffect(() => {
    setClipboardText('hello world');
  }, []);

  return (
    <Text>{clipboardText}</Text>
  );
}

[email protected] WARN `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.

Appeared in react-native 0.65.1 Android development:

WARN new NativeEventEmitter() was called with a non-null argument without the required addListener method.
WARN new NativeEventEmitter() was called with a non-null argument without the required removeListeners method.

It can be fixed like this https://github.com/invertase/react-native-firebase/pull/5616/files#diff-c887076b0c80d540aed1bfbb472cc8f20516634e8e72d53014c65d690bba4fb1

Synchronize Native Clipboard Across Android Devices

Describe the Feature

Many of us have more than one mobile devices and it would be so much convenient to have a way to synchronize the clips across all devices thereby eliminating the need to manually

Possible Implementations

Native Clipboard could be connected to free cloud software like dropbox, Gdrive, etc where the clips could be stored and other devices connected in a similar way could retrieve it so that the clips are available across all devices. Any device that makes any changes would be what would be reflected across other devices. Basically like mirroring

The other option is to be able to export/import clips to/from a file which is stored locally on the device. This file can then be transferred to other devices and thus the clips would be synchronized. Slightly more effort but does the job.

Image support

Describe the Feature

I'd like to be able to copy and paste images. Would the maintainers be open to a PR that adds support?

Possible Implementations

This should be pretty doable on iOS. There is a simplistic copy implementation on StackOverflow that I could update to use RCTImageLoader so that it would support any RN URI (including fake ones like the "ph://" protocol).

For paste on iOS, I could make an API that lets users pick between PNG/JPEG representations, as well as between having the file saved to disk or delivered as a base64-encoded data URI.

It appears that support on Android won't be as easy. This StackOverflow question addresses copy-paste of images on Android, and the tl;dr is that "copy/paste can only be achieved when the two applications work together". That said, the answer is pretty old, so this may have been gotten easier as of late. I can look into it more later.

`duplicate symbol '_OBJC_CLASS_$_RCTClipboard' in` when building in iOS

Environment

System:
OS: macOS 10.15.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 76.47 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.12.0 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 5.1.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5977832
Xcode: 11.2.1/11B53 - /usr/bin/xcodebuild
npmPackages:
react: ^16.10.2 => 16.11.0
react-native: ^0.61.2 => 0.61.4

Platforms

iOS

Versions

Latest

Description

After installing react-native-clipboard on a RN 0.61.4 project, I get the following error when building for iOS:

    /Users/diegolopez/Code/GitHub////ios/build/BetterHalf/Build/Products/Debug-iphonesimulator/React-Core/libReact-Core.a(RCTClipboard.o)
    /Users/diegolopez/Code/GitHub////ios/build/BetterHalf/Build/Products/Debug-iphonesimulator/react-native-clipboard/libreact-native-clipboard.a(RCTClipboard.o)
duplicate symbol '_OBJC_METACLASS_$_RCTClipboard' in:
    /Users/diegolopez/Code/GitHub////ios/build/BetterHalf/Build/Products/Debug-iphonesimulator/React-Core/libReact-Core.a(RCTClipboard.o)
    /Users/diegolopez/Code/GitHub////ios/build/BetterHalf/Build/Products/Debug-iphonesimulator/react-native-clipboard/libreact-native-clipboard.a(RCTClipboard.o)
ld: 2 duplicate symbols for architecture x86_64```

It seems like there's a clash between this library and react-core.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.