-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[local_auth] Implemented plugin to support local auth in macOS #5766
Changes from all commits
adbe9ea
9961983
558551f
3ef8b64
b92f169
b69905f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
## 1.2.0 | ||
|
||
* Renames the package previously published as [`local_auth_ios`](https://pub.dev/packages/local_auth_ios) | ||
* Adds support for macOS |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,6 +156,28 @@ - (void)showAlertWithMessage:(NSString *)message | |
dismissButtonTitle:(NSString *)dismissButtonTitle | ||
openSettingsButtonTitle:(NSString *)openSettingsButtonTitle | ||
completion:(FLAAuthCompletion)completion { | ||
#if TARGET_OS_OSX | ||
NSAlert *alert = [[NSAlert alloc] init]; | ||
[alert setMessageText:@""]; | ||
[alert setInformativeText:message]; | ||
|
||
if (openSettingsButtonTitle != nil) { | ||
[alert addButtonWithTitle:openSettingsButtonTitle]; | ||
[alert setShowsHelp:YES]; | ||
[alert setHelpAnchor:@"OpenSettings"]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where did this magic string come from; is there a default system help anchor with this name? This needs a code comment explaining it. |
||
} | ||
[alert addButtonWithTitle:dismissButtonTitle]; | ||
|
||
NSModalResponse response = [alert runModal]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should use You'll nee do adjust the plugin's |
||
|
||
if (response == NSAlertFirstButtonReturn) { | ||
NSURL *url = [NSURL URLWithString:@"x-apple.systempreferences:"]; | ||
[[NSWorkspace sharedWorkspace] openURL:url]; | ||
[self handleSucceeded:NO withCompletion:completion]; | ||
} else { | ||
[self handleSucceeded:NO withCompletion:completion]; | ||
} | ||
#else | ||
UIAlertController *alert = | ||
[UIAlertController alertControllerWithTitle:@"" | ||
message:message | ||
|
@@ -185,6 +207,7 @@ - (void)showAlertWithMessage:(NSString *)message | |
[[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:alert | ||
animated:YES | ||
completion:nil]; | ||
#endif | ||
} | ||
|
||
- (void)handleAuthReplyWithSuccess:(BOOL)success | ||
|
@@ -260,7 +283,12 @@ - (void)handleError:(NSError *)authError | |
|
||
#pragma mark - AppDelegate | ||
|
||
- (void)applicationDidBecomeActive:(UIApplication *)application { | ||
#if TARGET_OS_OSX | ||
- (void)applicationDidBecomeActive:(NSNotification *)notification | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does macOS need this flow at all? |
||
#else | ||
- (void)applicationDidBecomeActive:(UIApplication *)application | ||
#endif | ||
{ | ||
if (self.lastCallState != nil) { | ||
[self authenticateWithOptions:_lastCallState.options | ||
strings:_lastCallState.strings | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,10 @@ Downloaded by pub (not CocoaPods). | |
s.documentation_url = 'https://pub.dev/packages/local_auth_darwin' | ||
s.source_files = 'Classes/**/*' | ||
s.public_header_files = 'Classes/**/*.h' | ||
s.dependency 'Flutter' | ||
s.platform = :ios, '12.0' | ||
s.ios.dependency 'Flutter' | ||
s.osx.dependency 'FlutterMacOS' | ||
s.ios.deployment_target = '12.0' | ||
s.osx.deployment_target = '10.15' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why 10.15 rather than 10.14? |
||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } | ||
s.resource_bundles = {'local_auth_darwin_privacy' => ['Resources/PrivacyInfo.xcprivacy']} | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Flutter-related | ||
**/Flutter/ephemeral/ | ||
**/Pods/ | ||
|
||
# Xcode-related | ||
**/dgph | ||
**/xcuserdata/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" | ||
#include "ephemeral/Flutter-Generated.xcconfig" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" | ||
#include "ephemeral/Flutter-Generated.xcconfig" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
platform :osx, '10.15' | ||
|
||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency. | ||
ENV['COCOAPODS_DISABLE_STATS'] = 'true' | ||
|
||
project 'Runner', { | ||
'Debug' => :debug, | ||
'Profile' => :release, | ||
'Release' => :release, | ||
} | ||
|
||
def flutter_root | ||
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) | ||
unless File.exist?(generated_xcode_build_settings_path) | ||
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" | ||
end | ||
|
||
File.foreach(generated_xcode_build_settings_path) do |line| | ||
matches = line.match(/FLUTTER_ROOT\=(.*)/) | ||
return matches[1].strip if matches | ||
end | ||
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" | ||
end | ||
|
||
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) | ||
|
||
flutter_macos_podfile_setup | ||
|
||
target 'Runner' do | ||
use_frameworks! | ||
use_modular_headers! | ||
|
||
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) | ||
|
||
target 'RunnerTests' do | ||
inherit! :search_paths | ||
|
||
pod 'OCMock','3.5' | ||
end | ||
end | ||
|
||
post_install do |installer| | ||
installer.pods_project.targets.each do |target| | ||
flutter_additional_macos_build_settings(target) | ||
end | ||
end |
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.
Does this line actually do anything? What's the default value?