I am building a tweak for SMS sending on the default MobileSMS app coming with iOS 6.1. Even though I have managed to hook to the "Send" button, I cannot create a popup to inform the user, neither with UIAlertView
nor with a UIViewController
. I think the problem is that the CTMmsEncoder
class I am hooking to does not have a view controller to somehow override.
My question is if there is some way I can make a view appear in a situation like this. I have gone through many source codes for tweaks, but cannot find a similar case. I have even tried to create a dylib and load a a UIViewController from there, but get the (expected) error:
Oct 25 14:37:59 Pudge SpringBoard[950] <Warning>: Warning: Attempt to present <ModalViewController: 0x1dbbe1a0> on <KSMSDylibViewOne: 0x1db7da50> whose view is not in the window hierarchy!
When trying to implement a class with a ViewController directly in my tweak (say class ModalViewController), then Theos obviously outputs the error:
Tweak.xm:12:6: error: instance method 'presentViewController:animated:completion:' is being used on 'Class' which is not in the root class
[-Werror,-Wobjc-method-access]
[self presentViewController:view animated:YES completion:nil];
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Is there any way to get past this, or do I have to redesign?
Thank you in advance,
Panagiotis.
If you're simply looking to create something like what you get with UIAlertView
, you should be able to use CFUserNotificationCreate()
, even in a situation where you don't have a proper view hierarchy.
See this answer by KennyTM, or another one I posted here ... skipping to the Notify User from Daemon section, item (2).