Opening external application inside my application - iphone

Can I invoke another installed applications within my application? Suppose I have installed AngryBirds, I have to invoke that application by tapping a button from my application. Is it possible?

You can do it if the application in question has a defined protocol, in example if you want to call a number via skype you can perform an action like
NSString *contactName = #"user123";
NSURL *skypeURL = [NSURL URLWithString:[NSString stringWithFormat:#"skype://%#?call", contactName]];
if ([[UIApplication sharedApplication] canOpenURL:skypeURL]) {
[[UIApplication sharedApplication] openURL:skypeURL];
} else {
// Display to the user how to install skype.
}
the same can happen for other programs which have a protocol definition that could be understood.
And just 4 the record, here's a list of know URL Schemes
http://wiki.akosma.com/IPhone_URL_Schemes
Then, if you want your app to be URL-Scheme Compatible, you can have a good start by reading this:
http://www.idev101.com/code/Objective-C/custom_url_schemes.html
and this other post is really good and detailed.
How do you set your Cocoa application as the default web browser?
it explains how to make your app handle a custom URLScheme, which turns out to be your case.
hope it could be helpful.
k
for other case scenarios I got no idea if it is possible.

No, it's not possible to do that, unless the apps in question support URL Scheme, then you can launch it using URL.

Not possible, because all iphone apps will run in a different individual process with their own runtime environment. There is only a limited IPC(Inter process communication) available, that too for system libs and resources.

No. There is no way to open an another app within app. However you can open an different app from your app vise versa by using
URL Scheema
Open_In functionality using CFBundleDocumentTypes and UIDocumentInteractionController.

Related

How can I block custom applications using URL schemes in iPhone?

I have worked a bit with URL schemes and have managed to access a custom app that i created using another app. My requirement is to block my custom apps once the battery level goes less than a certain level.
Is there any way to do that? What data will I have to pass through the URL scheme?
By block i mean either disable or uninstall completely. Just seeking some control.
You cannot completely block your application from launching if it's being opened through URL scheme. I suggest checking whether your app is launched by opening a scheme and then just display an alert view with a notice that your app requires the phone to have more battery power (or be charging).
i think you should use push notification, it can handle your requirement

Get extern [UIApplication sharedApplication]?

I am currently developing an "in device" (not simulator) monitoring system for an iPad app. The system should be able to do the following:
-User input simulation: Simulate user inputs: taps, drags, keyboard.
-Information recollection: Get text values and results after doing inputs.
This information will be later reported to an event management server. I have already taken care of the two points in a single app, by using some code from KIF software https://github.com/square/KIF and some self developed code. I use the accessibleName property of the UIView objects to get their pointer and send artificial events to the [[UIApplication sharedApplication] sendEvent:] method.
Here’s the thing: I need to send these events from app#1 in which I am, to app#2. (To keep the monitoring independent, also embedding all the code in app#2 is not an option) I use the [[UIApplication sharedApplication] openURL:] method to open the app#2.
https://developer.apple.com/library/IOs/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW18
The problem is, I cannot send events from app#1 to app#2 because I cannot seem to get the pointer to the [UIApplication sharedApplication] object of app#2 in the app#1 code.
A shared memory communication between the processes would be great, but according to the information that I found, the URL messaging scheme seems to be the only communication between apps (or processes) in iOS. The NSConnection class is also not present in iOS. I've also read a little bit about Mach ports and POSIX file descriptors, but they seem fairly complicated and I have no idea if they can help.
I even tried to send the value of the pointer of the app#2 [UIApplication sharedApplication] instance as a string parameter in the URL message, then converted the string back to a pointer in app#1, but got a EXC_BAD_ACCESS. I suppose the pointer address does not mean the same in both processes. Maybe each process has its own "offset"?
Any help would be greatly appreciated.
In first instance I wold clarify that what you want to do is not possibile without private APIs.
Each app is sandboxed and you cannot access to other apps (directly). I think that your problem is really big.
Each app running in iOS is like small, independent, eco-system that ends when the user press the 'Home' button (except if you declare some background services like VOIP, localization or audio player). Once the app has been closed the only thing that you can still run is a process that should not be longer than 10 mins. This is to prevent an excessive usage of background tasks and even here, the app isn't accessible from other apps.
I think the only way is to search for private APIs, hoping someone else already found a way to create a data streaming (directly) between 2 apps.

Launch another app from myapp without url scheme - jailbreak users are able to, so how?

i'm trying to write a small application, a "launcher" app, that comes up when i plug my phone to power supply. Now there should be a 4x4 grid with my fav app i want to load. therefore no problem.
But how to start an app from an app? I read dozens of times that is is not possible, to do it without url shemes like tel://
How are jailbreak applications able to to this? Like Activator, PluggedIn, iSheduler...
I have them running on my phone, and they are able to start any application, also my own, which don't have url scheme.
I tried lauchner from Erica Utilities, but it just crashed.
It is possible, but how?
Thanks for any advice
Greetings Max
You can activate an app by importing these classes:
SBApplicationController
SBUIController
SBApplication
The SBApplicationController gets your app, the SBApplication, and then opens it using the SBUIController like so:
Class SBApplicationController=objc_getClass("SBApplicationController");
SBApplication *app=[[SBApplicationController sharedInstance] applicationWithDisplayIdentifier:#"com.company.yourapp"];//change the bundle identifier for whichever app you want
[[objc_getClass("SBUIController") sharedInstance] activateApplicationFromSwitcher:app];
Finally i found a solution: open - a commandline tool by Conrad Kramer:
http://thecydiastore.com/app/com.conradkramer.open/

Link to iTunes Ratings Page

What's the link to the ratings page on iTunes for my app?
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"???"]];
This other question has an appropriate answer. Note that the type=Purple+Software part is literal and not the name of your company. The only thing you need to change is the app id. This example is a little strange in that the string is broken up into several strings, I would just use one for the format to substitute the app id.
The end result looks like this:
itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=123456789
after iOS7 #Jon Steinmetz link deprecated. so, you should write a code divide os version as follows.
if([[UIDevice currentDevice] systemVersion].floatValue >= 7.0f)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://itunes.apple.com/app/id%#", #YourAppID#]]];
else
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=%#&pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8", #YourAppID#]]];
Creating a rating link could become a complex issue when supporting multiple OS and multiple platform. For example the WebObjects isn't supported on iOS 7 (some of them), some links you create would open another country store then the user's etc.
There are 2 related open source libraries that could help you:
iLink - There the link would be found at run time (the library would check the app ID and the OS it is running on and would figure out what link should be created). The best point in this is that you don't need to configure nothing before using it so that is error free and would work always. That's great also if you have few targets on same project so you don't have to remember which app ID or link to use. This library also would prompt the user to upgrade the app if there is a new version on the store (this is built in and you turn this off by a simple flag).
Copy the 2 library files to your project.
On your appDelegate.m:
#import "iLink.h"
+ (void)initialize
{
//configure iLink
[iLink sharedInstance].globalPromptForUpdate = YES; // If you want iLink to prompt user to update when the app is old.
}
and on the place you want to open the rating page for example just use:
[[iLink sharedInstance] openRatingsPageInAppStore];
and import iLink.h on the same file.
There is a very good doc for the whole library there and an example projects for iPhone and for Mac.
iRate - This library is super recommended if you want the library to prompt the user rating process automatically. Just set the parameters you want and it would do the work for you (also have translations for lots of languages). The downside is that you would use an alert view for that and not your own UI.

How do you prompt the user to rate your iphone app without waiting for them to delete the app?

I am referring to the popup window that asks the user to submit a review/rating.
I know it can be done since the Aardark app does it...it asks several times in fact! (Almost too spammy.) But there has to be an API to trigger the rating request? Google is giving me no love on this one.
I would check out the Appirater project that Arash Payan has put together.
Pretty much handles the checking and displaying of the "rate my app" prompt, and brings the user right into the review portion of your app on the App Store.
It's a very clean, and elegant way to provide that minimum barrier so that your users are more likely to submit reviews of your app.
Hope this helps...
I have written about a way to open right into the review panel of the App Store.
http://www.memention.com/blog/2009/09/03/Open-Reviews.html
The actual code part if called through a button press could look like below
- (IBAction)gotoReviews:(id)sender
{
NSString *str = #"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa";
str = [NSString stringWithFormat:#"%#/wa/viewContentsUserReviews?", str];
str = [NSString stringWithFormat:#"%#type=Purple+Software&id=", str];
// Here is the app id from itunesconnect
str = [NSString stringWithFormat:#"%#289382458", str];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}
I wrote a library to do this - similar to Appirater but a bit more configurable and with Mac App Store support:
https://github.com/nicklockwood/iRate
I have discovered the most subtle value of S.O. (already obvious to all elementary school teachers) --- often by simply forming your question, your neurons rearrange and you are more successful at answering it yourself! (Either that or Google optimized my search after spying on my keystrokes and indexing my question on S.O.)
Answer found after more productive googling:
http://www.mobileorchard.com/fighting-back-against-the-app-stores-negative-rating-bias/
this may not be what youre looking for EXACTLY but what i would do is just prompt them in the app somehow and somewhere not too annoying with a button or alert view and have that button link them to app url in safari which opens the appstore to your app. you can use the url http://www.itunes/apps/ (your app) as i believe is the synthax. i cant remember the exact code but i can get it for you if need it.
We AskingPoint have another way to do it (Im a founder) that provides BOTH App Analytics and the rating widget. You can adjust server side settings based on your analytics to prompt only your best users. Change settings on the fly. And it's translated into over 30 languages.
I wanted to do this when I roll the app out for the first time... looks like I'll have to wait and put it out as an update to ensure that it will work... let me know if I am wrong and there is some way I can test this before submitting to apple for distribution.