Skip to content
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

Checking the pasteboard for dynamic links in ios14 #5905

Merged
merged 11 commits into from
Jun 29, 2020
Merged

Conversation

ncooke3
Copy link
Member

@ncooke3 ncooke3 commented Jun 24, 2020

In iOS14, a notification will be be displayed to the user whenever an app reads from the pasteboard. Since dynamic links reads from the pasteboard at launch, it will cause this notification. Using the UIPasteboard's new detectPatternsForPatterns: api, we can try detecting if the pasteboard contains a dynamic link as its first item so we don't trigger the notification needlessly.

Draft PR following up on #5893

@ncooke3 ncooke3 requested a review from ryanwilson June 24, 2020 18:11
@ncooke3 ncooke3 added api: dynamiclinks beta-software Related to using beta iOS or Xcode versions. labels Jun 24, 2020
}];

} 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

}
dispatch_semaphore_signal(semaphore);
}];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
Copy link
Contributor

Choose a reason for hiding this comment

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

wdyt about using a completion handler for retrievePasteboardContents instead of waiting and returning a string from this method?

Copy link
Member Author

@ncooke3 ncooke3 Jun 25, 2020

Choose a reason for hiding this comment

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

I think that is a valid approach too but Im not sure how that would change the initial call here. It might require more refactoring for that method, which im not sure is worth it considering this proposal PR is not really a fix. Im not too sharp at handling async methods in objc c though so if you can make it cleaner, feel free! 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

For proposal PR it should be fine. Otherwise as you can see, this method will get called from app start up and we don't want to freeze the app by waiting here to check the pasteboard.

@ryanwilson ryanwilson requested a review from eldhosembabu June 29, 2020 19:50
@ryanwilson
Copy link
Member

This change LGTM - I tested myself that the hasURL call works as expected and this should at the very least reduce the notifications to only when a URL is on the clipboard. We should evaluate how we can do better, but this is an improvement to start.

@ryanwilson
Copy link
Member

Please wait for @eldhosembabu review before merging @ncooke3

@paulb777 paulb777 marked this pull request as ready for review June 29, 2020 20:23
Copy link
Contributor

@eldhosembabu eldhosembabu left a comment

Choose a reason for hiding this comment

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

The changes looks good to me

@eldhosembabu
Copy link
Contributor

Please add the change log entry before merging.

@morganchen12 morganchen12 added this to the 6.28.0 - M75 milestone Jun 29, 2020
@ncooke3 ncooke3 merged commit f7ccdef into master Jun 29, 2020
@ncooke3 ncooke3 deleted the nc-dl-ios14 branch June 29, 2020 23:00
granluo pushed a commit that referenced this pull request Jul 7, 2020
* 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
@firebase firebase locked and limited conversation to collaborators Jul 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: dynamiclinks beta-software Related to using beta iOS or Xcode versions. cla: yes
6 participants