From 0a335b23eec698f22d1e3e418de8066f034b4cdb Mon Sep 17 00:00:00 2001 From: iddoeldor Date: Fri, 17 Aug 2018 17:31:16 +0300 Subject: [PATCH] add ios alert box example --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 7501b3b..2b82210 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ - [Await for specific module to load](#await-for-condition) - [Android make Toast](#android-make-toast) - [Hook java io InputStream](#hook-java-io-inputstream) + - [iOS alert box](#ios-alert-box) - [TODO list](#todos) #### Intercept and backtrace low level open @@ -455,7 +456,21 @@ function hookInputStream() { Java.perform(hookInputStream); ``` +#### iOS alert box +``` +var UIAlertController = ObjC.classes.UIAlertController; +var UIAlertAction = ObjC.classes.UIAlertAction; +var UIApplication = ObjC.classes.UIApplication; +var handler = new ObjC.Block({ retType: 'void', argTypes: ['object'], implementation: function () {} }); +ObjC.schedule(ObjC.mainQueue, function () { + var alert = UIAlertController.alertControllerWithTitle_message_preferredStyle_('Frida', 'Hello from Frida', 1); + var defaultAction = UIAlertAction.actionWithTitle_style_handler_('OK', 0, handler); + alert.addAction_(defaultAction); + // Instead of using `ObjC.choose()` and looking for UIViewController instances on the heap, we have direct access through UIApplication: + UIApplication.sharedApplication().keyWindow().rootViewController().presentViewController_animated_completion_(alert, true, NULL); +}) +```