Skip to content

Commit

Permalink
hmm
Browse files Browse the repository at this point in the history
  • Loading branch information
YellowCat98 committed May 26, 2024
1 parent d8ac226 commit 1a188be
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/iGeodeLib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ namespace iGeodeLib {
void showAlert(const char *title, const char *message, const char *Btn);
std::string iOSVersion();
void CShowAlert(const char *title, const char *message, const char *Btn, std::function<void()> callback = nullptr, const char *Btn2 = nullptr, std::function<void()> callback2 = nullptr);
void faceID(std::function<void()> callback, std::function<void()> callback2);
}
#endif // IGEODELIB_HPP
27 changes: 24 additions & 3 deletions src/iGeodeLib.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <functional>
#include <string>
#include "iGeodeLib.hpp"
#import <LocalAuthentication/LocalAuthentication.h>
namespace iGeodeLib {
/*
shows a system level alert.
Expand Down Expand Up @@ -88,13 +89,33 @@ void CShowAlert(const char *title, const char *message, const char *Btn, std::fu
} else {
showAlert("Update Required", "Update to iOS 17.4", "shut up");
}
*/
std::string iOSVersion() {
UIDevice *device = [UIDevice currentDevice];
NSString *iOSVersion = [device systemVersion];
return [iOSVersion UTF8String];
}
/*
prompts for face ID
example usage:
faceID(myCoolFunction(), myFailureFunction());
*/
void faceID(std::function<void()> callback, std::function<void()> callback2) {
LAContext *context = [[LAContext alloc] init];
NSError *error = nil;

if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:@"Auth."
reply:^(BOOL success, NSError *error) {
if (success) {
callback();
} else {
callback2();
}
}];
} else {
ShowAlert("Unsupported.", "Your device doesnt support Face ID", "Cancel");
}
}
}
6 changes: 1 addition & 5 deletions src/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ using namespace geode::prelude;

class $modify(MenuLayer) {
void onMoreGames(CCObject*) {
std::string iOSVersionStr = iGeodeLib::iOSVersion();

std::string iOSVersion = "You are running iOS" + iOSVersionStr;

FLAlertLayer::create("Hello", iOSVersion.c_str(), "idc")->show();
iGeodeLib::faceID(showAlert("Face ID Success!", "cool face id", "idc"), showAlert("fail", "no face id", "bro shut up"));
}
};

0 comments on commit 1a188be

Please sign in to comment.