Custom iOS popup/modal view jailbreak launch daemon - ios

I'm working on a jailbreak tweak (launch daemon) that simply listens for a certain event then will need to display a custom popup UIView when that event occurs. The popup needs to appear wherever - so either lockscreen, springboard or in app.
Whilst I have managed to get a simple CFUserNotificationDisplayAlert working, it does not offer the required functionality - I would prefer a custom view to be rendered.
I have tried using the RNBlurModalView library here, but this crashes when attempting to render the view as it looks for a base UIViewController - there isn't one as it's a background daemon.
Does anyone have any tips how I can go about rendering a custom popup view (whether it's modifying the above RNBlur library or rolling a different solution)?
Thanks! :)

What you can do is inject a dynamic library into SpringBoard in which you use the CPDistributedMessagingCenter class in server mode and you set it up in a way so that it listens for a message, then upon receiving that message, its observer object renders the custom view and adds it to the key window of the SpringBoard application itself ([[UIApplication sharedApplication].keyWindow addSubview:customView];).
Then, in the other part of the tweak (where you're currently calling CFUserNotificationDisplayAlert()), you simply use CPDistributedMessagingCenter in client mode and send it the appropriate message whenever needed.

Related

What architecture can I use to change screens in Swift when there's an event outside of the current view?

For example, I have a Notification that occurs when there is an "unauthorized" error returned from the api server that should bring the user back to the login screen. This event could appear anywhere in the program.
Do I create a new viewless controller to manage states and have it monitor for this notification and then present the login view controller?
I'm thinking about push notifications too, received by the app delegate. Some of these may cause the data model to get updated and then the screen to change. Who should make the screen change? In the past I put all this in the AppDelegate. But there must be a more elegant way!
I also found out about FlowControllers. But they don't play nicely with Interface Builder, at least according to this solution.
Please let me know if you need more specific information about my project.

IOS initial view controller based on condition retrieved from database

An iOS app I'm creating shows a setup screen upon first launch which requires data to be written to the database.
Upon launch, I need to access this value form the database.
If it is set, launch main view controller
Else show setup view controller.
As far as I'm aware theres two ways I can do this, programmatically setting it from the AppDelegate or using an initial View Controller as a splash screen and performing the look up and segue there.
What would be the best way to approach this? Is it wrong to do a database lookup in didFinishLaunchingWithOptions?
Using a splash screen is probably the better option as it provides better scope for modification in the future and allows you to update the user on progress. It is fine for the app delegate to run logic to determine how the app starts but you should endeavour to keep the app delegate minimal and focussed.
I very much doubt that you would get this approved (if your goal is the App Store). Your app delegate needs to create a window, and set a rootViewController to that window before it returns YES in appFinishLaunching:
You simply do not have enough time to check with a server before creating the first viewController and you'll be creating poor interface if you try. I suggest the first ViewController will need to be informing the user that it is checking with the server with an activityIndicator or something. The best :)

Global app remote notification response ios

I would like to implement a similar response system for push notifications throughout my app. When a remote notification appears and the application is in the active state I would like to place a button temporarily on the screen that performs the same action regardless of where it is in the app.
The only way I can think to do this is to create the same response to notification method in each of the app's many view controller.
Is there any way to do this in the app delegate, tab bar, or navigation bar so that the same response would apply to multiple views rather than placing the same function in each view controller separately?
Please advise and thanks
If I understood your question correctly: your problem is not related to notifications at all, but rather how to place a button on top of all views. A common way would be to add it as a subView to the window.
As a starting point: AwesomeMenu on GitHub

Synch call on willFinishLaunchingWithOptions (AppDelegate)

I would to do a remote call before the app is started (in AppDelegate, when the splash screen is showed). Then i would to choose which view controller to load based on url response.
Is right to do this on AppDelegate? Or I need a different approach?
I think the best approach is creating a ViewController where you make this choice. Once this VC is loaded you make your remote call while showing in the UI that your app is actually working and waiting for a network response - the best approach is probably showing a message with a UIActivityIndicatorView spinning.
Once you get the response you load the VC that you need. You should also handle errors - what are you going to show if the network request fails? Are you showing an error message?
You should not do any synchronous network calls from willFinishLaunchingWithOptions. If you take more than a few seconds to return that method or (didFinishLaunchingWithOptions, or the other app delegate methods that the system calls in the process of launching your app) then the springboard will terminate your app as unresponsive.
#Tanzolone has the right idea. Have your app display a view controller that shows your app's UI, THEN invoke the network request and decide what second screen to switch to based on the response.

IOS: turn off camera

In my app I use iphone camera, but the process is very low when I open it; then I want to start the process when I shows a splashscreen.
The problem is that when splashscreen ends I don't want to show camera.
Then while I show splashscreen I want to start process of camera and quit it before splashscreen disappear. Is it possible?
First up, Apple specifically advise against using splash screens in their Human Interface Guidelines document. I don't know if your app would get rejected for it, but best not to try.
Second, it sounds like you need to optimise the startup of your application and probably the first view controller. To do this, you need to put off loading/initialising everything you can until it's actually needed (known as "lazy initialisation). All code in applicationDidFinishLaunching: in your app delegate and your view controller's init method, loadView, viewDidLoad, viewWillAppear, viewDidAppear should be reviewed for stuff that could be done later.

Resources