Skip to content

Checking the pasteboard for dynamic links in ios14 #5905

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

Merged
merged 11 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions FirebaseDynamicLinks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Unversioned
- [fixed] Reduce frequency of iOS14 pasteboard notifications by only reading from it when it contains URL(s). (#5905)

# v4.3.0
- [changed] Functionally neutral updated import references for dependencies. (#5824)

Expand Down
14 changes: 13 additions & 1 deletion FirebaseDynamicLinks/Sources/FIRDLDefaultRetrievalProcessV2.m
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ - (void)markCompleted {

- (nullable NSURL *)uniqueMatchLinkToCheck {
_clipboardContentAtMatchProcessStart = nil;
NSString *pasteboardContents = [UIPasteboard generalPasteboard].string;
NSString *pasteboardContents = [self retrievePasteboardContents];
NSInteger linkStringMinimumLength =
expectedCopiedLinkStringSuffix.length + /* ? or & */ 1 + /* http:// */ 7;
if ((pasteboardContents.length >= linkStringMinimumLength) &&
Expand All @@ -296,6 +296,18 @@ - (nullable NSURL *)uniqueMatchLinkToCheck {
return nil;
}

- (NSString *)retrievePasteboardContents {
NSString *pasteboardContents = @"";
if (@available(iOS 10.0, *)) {
if ([[UIPasteboard generalPasteboard] hasURLs]) {
pasteboardContents = [UIPasteboard generalPasteboard].string;
}
} else {
pasteboardContents = [UIPasteboard generalPasteboard].string;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line alone will trigger the notification to be displayed!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the line 306 will be executed only on iOS < 10 therefore no popup.

Still the line 303 will trigger a popup, but I guess the point was to just "reduce" the popups (check the Changelog

}
return pasteboardContents;
}

- (void)clearUsedUniqueMatchLinkToCheckFromClipboard {
// See discussion in b/65304652
// We will clear clipboard after we used the unique match link from the clipboard
Expand Down