Skip to content

Commit f7ccdef

Browse files
authored
Checking the pasteboard for dynamic links in ios14 (#5905)
* Checking the first pasteboard item in ios14 * Cleaned up method and added ifdef * Renamed variable * Style * Refactored method * Using another url detecting api * Made sure pasteboardContents is initialized * Changelog * Update Changelog * Removed trailing space
1 parent d653c95 commit f7ccdef

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

FirebaseDynamicLinks/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Unversioned
2+
- [fixed] Reduce frequency of iOS14 pasteboard notifications by only reading from it when it contains URL(s). (#5905)
3+
14
# v4.3.0
25
- [changed] Functionally neutral updated import references for dependencies. (#5824)
36

FirebaseDynamicLinks/Sources/FIRDLDefaultRetrievalProcessV2.m

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ - (void)markCompleted {
270270

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

299+
- (NSString *)retrievePasteboardContents {
300+
NSString *pasteboardContents = @"";
301+
if (@available(iOS 10.0, *)) {
302+
if ([[UIPasteboard generalPasteboard] hasURLs]) {
303+
pasteboardContents = [UIPasteboard generalPasteboard].string;
304+
}
305+
} else {
306+
pasteboardContents = [UIPasteboard generalPasteboard].string;
307+
}
308+
return pasteboardContents;
309+
}
310+
299311
- (void)clearUsedUniqueMatchLinkToCheckFromClipboard {
300312
// See discussion in b/65304652
301313
// We will clear clipboard after we used the unique match link from the clipboard

0 commit comments

Comments
 (0)