react-native-clipboard / clipboard Goto Github PK
View Code? Open in Web Editor NEWReact Native Clipboard API for both iOS and Android.
License: MIT License
React Native Clipboard API for both iOS and Android.
License: MIT License
null is not an object (evaluating 'u.default.setString')
on using sample code in expoNo 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!
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.
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();
* }
* ```
*/
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
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.
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
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
iOS
Latest
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.
It would be very useful to have a clipboard event listener.
Possible implementation here: https://github.com/stefanc96/react-native-clipboard-listener
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
both
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
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
both
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
iOS 14
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.
Install library
[*] After install and import i got this below error.Why?
iOS
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.
Test the sample project in a simulator on iOS16
react-native 0.63.3
Android
cannot get the clipboard content when app Toggle front and back, only Kill the app, open again and get it
iOS
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.)
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
Android
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
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
Android
Instead of the clipboard object null
is returned.
https://snack.expo.io/@aboutreact/clipboard-example?session_id=snack-session-45GVESXWi
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
Android
I found that build.gradle file is missing, so the gradle sync failed.
With the upcoming new architecture of react native, it would be nice to start moving the packages over to the new arch. I couldn't find any references to new arch for this package, which is why i'm opening the issue
Implementing the steps under https://reactnative.dev/docs/next/new-architecture-library-intro
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.
Both
When i try add package in my project, yarn can't found the package.
How to set text to make it a hyperlink (that every app treats it as hyperlink)
Also if how to make an hyperlink with different title(may be name of the app) and different link (link to play/app store URL)
React Native with Expo 39
Android
...
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.
add an option for pasteboard types example:
@"org.nspasteboard.ConcealedType"
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.
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
iOS
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
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?
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.
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
Clipboard API should support web environments
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.
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
Clipboard.hasString()
has been implemented in #73
Clipboard.hasURL()
has been implemented in #78
Clipboard.hasBool()
Clipboard.hasImage()
?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
Android
Today i was building my debug app on android as usual but i got this:
i tried: running./gradlew clean and upgrading the library but didnt help
Any suggestions?
Thanks
iOS
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!
Task :app:mergeDebugJavaResource FAILED
Task :app:mergeDebugNativeLibs FAILED
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
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.
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
Android
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)
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
react-native-inappbrowser-reborn
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)
use microsoft/react-native-test-app for example app
example implementation can be found in https://github.com/react-native-menu/menu
const copyToClipboard = () => {
Clipboard.setString(text);
};
after triggering this I think we should have a toast over there.
I'd like to be able to copy and paste images. Would the maintainers be open to a PR that adds support?
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.
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);
}
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?
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
Both
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.
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
iOS
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
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
Confirmed at least ios
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'
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
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.
/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"
}
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
MacOS web
Shown above
Just using useClipboard() causes "TypeError: Cannot read property 'getString' of undefined".
FWIW, I'm also using TypeScript.
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>
);
}
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.
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
react-native run-android
Android
When I do the build to emulate the android, with the following command: react native run-android the cliboard library returns the error attached
npx react-native run-android
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
iOS, not sure about Android, it is possibly (and probably) also affected.
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')
Clipboard.setString("Test"); // Errors out
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.