-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2036c2
commit 5fa9fa5
Showing
4 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import 'dart:io'; | ||
|
||
import '../utils.dart'; | ||
|
||
void main(List<String> arguments) async { | ||
List<String> platforms = getPlatforms(arguments); | ||
|
||
final androidPermissions = [ | ||
'<uses-permission android:name="android.permission.USE_BIOMETRIC"/>', | ||
]; | ||
|
||
final iOSPermissions = [ | ||
{ | ||
'key': 'face_id_description', | ||
'value': 'NSFaceIDUsageDescription', | ||
} | ||
]; | ||
|
||
try { | ||
// Add the biometric permission to AndroidManifest.xml | ||
if (platforms.contains('android')) { | ||
updateAndroidPermissions(permissions: androidPermissions); | ||
|
||
// Update MainActivity to extend FlutterFragmentActivity | ||
final mainActivityUpdates = { | ||
'kotlin': [ | ||
{ | ||
'pattern': | ||
r'import\s+io\.flutter\.embedding\.android\.FlutterActivity', | ||
'replacement': | ||
'import io.flutter.embedding.android.FlutterFragmentActivity' | ||
}, | ||
{ | ||
'pattern': r'class\s+MainActivity\s*:\s*FlutterActivity\(\)', | ||
'replacement': 'class MainActivity: FlutterFragmentActivity()' | ||
} | ||
], | ||
'java': [ | ||
{ | ||
'pattern': | ||
r'import\s+io\.flutter\.embedding\.android\.FlutterActivity;', | ||
'replacement': | ||
'import io.flutter.embedding.android.FlutterFragmentActivity;' | ||
}, | ||
{ | ||
'pattern': | ||
r'public\s+class\s+MainActivity\s+extends\s+FlutterActivity', | ||
'replacement': | ||
'public class MainActivity extends FlutterFragmentActivity' | ||
} | ||
] | ||
}; | ||
|
||
updateMainActivity(mainActivityUpdates); | ||
} | ||
|
||
// Add Face ID usage description to Info.plist for iOS | ||
if (platforms.contains('ios')) { | ||
updateIOSPermissions(iOSPermissions, arguments); | ||
} | ||
|
||
print('Biometric enabled successfully for ${platforms.join(', ')}! 🎉'); | ||
exit(0); | ||
} catch (e) { | ||
print('Starter Error: $e'); | ||
exit(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters