My iOS application (using Swift) needs to react to a user having opened another application. It does not necessarily need to know what app it is. It just needs to know that the app being opened is not the phone call/dialer app, because the dialer app would be the only app that receives an exception from my application. I do not want to stop the user from opening the other apps, but just have my app react to that action.
I know it is possible, because there is an app on the app store that uses this functionality currently. The app I am referring to is called Forest- Stay Focused. It seems like I should be able to use the AppDelegate functions somehow, but I cannot seem to figure out how.
How can I accomplish what I am looking to do?
Related
I understand that your application is sandboxed in Apple environment. But I have a need to know the application that user currently is playing with - just the name is enough in my application which is currently in background.
Is there any possibility to know the application name which is currently in foreground?
Please do not down vote. My intention is to check if somebody has used some private API in the past to do this.
In my app, Can I check that which app is being used by a user right now, while my app is running in background?
If so, Is there any API available to get that info?
thanks in advance!
No. There's no public API that lets you a background app find out about the foreground app, or get a list of running apps, or anything like that.
The only mechanism for finding out about other apps on the device is +[UIApplication canOpenURL:], which you can use in some cases to find out whether a specific custom URL scheme can be handled. From that you can often guess that a particular app is installed, although the method really only tells you that some app that can handle the given scheme is installed. However, you still can't find out if that app is the foreground app, or even if it's running at all.
I'm using Calaba.sh to to ui testing of my iOS app. I want to be able to test tapping on a link in the app which takes the user to a web address in their browser. I then want to be able to resume the app. Is there a way to do this?
This is not possible in Calabash iOS.
Is there a way for an app which does this (and requires no UI) to be accepted by Apple's App Review process?
I know that simply putting exit(0) in applicationDidFinishLaunching:withOptions: will be rejected, but what if the exit(0) is called only upon completing a TCP transaction? Does Apple reject any attempt to exit your app?
Here's what I'm looking for. I make a file in some iOS app (a picture for instance) and I open it up in my app with "Open In...". I'd like for my app to perform a function which requires no user input (i.e., sending it to a preconfigured network location). Then I would like for my app to quit, returning to the app from which I used the "Open In..." feature.
I take it that if I am completely forbidden from exiting, then the most optimal possible workflow is probably the 4-finger swipe back to the calling app. It is also not very clear what my app would do when opened regularly (from the home screen), but that's not really a big problem.
What you want to do can't be done plus there is no point. Apple will never approve such an app. All apps must have a useful purpose in their own right. If the only use of your app is to send files from other apps to some server, it is of no use by itself. Apple expects each app to have a fully functional and useful user interface.
But all of that aside, here is why this can't be done - You are given no way to relaunch the calling app. When your app is launched, ultimately the UIApplicationDelegate method application:openURL:sourceApplication:annotation: will be called. This tells you what file to process and it gives you the bundle id of the requesting app. But there is no information that allows you to launch the app that launched yours. There is no API that let's you return to the previous app.
The only possibility is if the calling app explicitly launches your app and provides a return URL. But this eliminates and general use. Any app that would work with your app would need specific code in place to support your app. Obviously this is far from a general purpose solution.
BTW - having your app simply exit is of no benefit as that doesn't return the user to the previous app.
Assuming you own both apps, you don't have to exit your app at all. In fact, doing so wouldn't bring the other app back to the foreground anyway.
Just use the standard linking technique in both directions.
I am new to programming for iOS and need some guidance on how to link to a website after an app gets deleted. For example, when a user clicks the "X" button, removes the app and any data it stored, the code should open a website.
Is this possible?
No, Apple does not allow you to hook in the SpringBoard to detect app deletion.
There is no work around, it's not possible.