-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Expose hasString method for iOS 14+ #73
Conversation
ios/RNCClipboard.m
Outdated
RCT_EXPORT_METHOD(hasString:(RCTPromiseResolveBlock)resolve | ||
reject:(__unused RCTPromiseRejectBlock)reject) | ||
{ | ||
bool stringPresent = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: BOOL
should be preferred in ObjC, with YES
or NO
as values.
See https://stackoverflow.com/questions/541289/objective-c-bool-vs-bool
ios/RNCClipboard.m
Outdated
stringPresent = clipboard.hasStrings; | ||
} else { | ||
NSString* stringInPasteboard = clipboard.string; | ||
stringPresent = stringInPasteboard != nil; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it be empty too?
Awesome! Can we implement stuff from #64 also? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gnardini amazing! tested on example app and seems to be working great.
sorry for the example project on this repo not working for you, there was a typo in podfile which was preventing the example to work, but now it's fixed.
I'm finding that |
Firstly, thanks for the work on the clipboard!
Overview
iOS 14 now shows a notification each time an app accesses the clipboard, so we need to be more careful on when to read it. It also has a new API that allows apps to tell if there's any content on the clipboard or not. The API has more methods than the one I implemented, I just added the one I needed. I don't have time to keep working on this unfortunately to add the rest of the methods :( I understand if you think this is not enough to merge.
Test Plan
Unfortunately, the example project didn't compile for me, so I couldn't use that one to test, I tested directly on my own project.
To test you need an iOS 14 device and one with an older version. On both of them add a call somewhere to
await Clipboard.hasString()
. Do so while having content on the clipboard and while having an empty clipboard. You could print the result of the call toconsole.log
or any other logger to see that the correct value is returned.