add ios alert box example
This commit is contained in:
parent
094f212b29
commit
0a335b23ee
15
README.md
15
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);
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user