How To Check Installed Application On iPhone Device - iphone

I am developing an application in which I need to find the apps - such as Skype, Facebook - which are already installed on the iPhone device.
I need to check it Objective-C. Please give me a code snippet if possible; otherwise a link to the solution.
If it not possible then tell me another way to check installed application on iPhone device.
Thanks in advance.

If the app you're checking for has a URI scheme registered, you can probe for that and assume the app is installed. Have a look at -(BOOL)canOpenURL:(NSURL *)url, try something along the lines of
if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"fb://"]] )
{
NSLog(#"will open facebook urls");
}
However, this does not give the guarantee that the genuine facebook app will respond to fb://

if ([[NSFileManager defaultManager] fileExistsAtPath:#"/Applications/Cydia.app"])

Related

iPhone App Button To Go To App Store and Leave a Review

I am trying to set up app where user can touch a button and go to the App Store to leave a review. I am using iPhone simulator 5.0 and I keep getting the address is invalid.
I am using this format:
-(IBAction) leaveReview {
NSString *reviewURL = #"itms-apps://itunes.apple.com/us/app/mood-color-secrets-women/id495880078?ls=1&mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:reviewURL]];
}
The address works in Safari as:
http://itunes.apple.com/us/app/mood-color-secrets-women/id495880078?ls=1&mt=8
Do I have a format error? or Is something changed in iOS 5.0?
Is there an easy solution I am missing?
The itms-apps://... address is only works on devices.
BTW, try Appirater, a utility that reminds your iPhone app's users to review the app.
Have you tried this on a physical iOS device? If not, I think the issue may be that the iOS Simulator does not feature the AppStore. Therefore, since the URL Scheme says "itms-apps", the simulator is not finding the AppStore, so it will not open.
For my Apps, I've used the following format (I put it in terms of your example.)
// Where 123456789 is the App ID
NSString *reviewURL = #"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=123456789";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:reviewURL]];

How do I open a user's Twitter profile using the Twitter app using a link in Mobile Safari?

It looks like Twitter registers the URI scheme of twitter://, but after playing around with it I can't get it to directly open a user's profile. I've tried:
twitter://username
twitter://user/username
twitter://profile/username
with no luck. I'll need it to work on Android as well.
Thoughts?
I found two URL schemes for twitter tweetie:// and twitter://:
tweetie:///user?screen_name=jessicaalba
twitter:///user?screen_name=jessicaalba
On this wiki site you can find a lot of other iphone url schemes (including twitter)
Doesn't seem to be official documented anywhere so I wouldn't count on all versions of the Twitter app supporting it but http://groups.google.com/group/twitter-development-talk/browse_thread/thread/92b958b7af002993?pli=1 gives a hint that might be worth a try:
I just found that "twitter:///user?screen_name=tvdw" works as well.
I know you are looking specifically to open it up with the official Twitter app but what if the person doesn't have the app, then the functionality will not work in your app.
Why not just use MGTwitterEngine in this case since it will work for everyone and it will remain in your app?
For those wondering how to test if the scheme executes:
- (BOOL)openURL:(NSString *)url
- (void) clickTwitter {
if (![self openURL:#"twitter:///user?screen_name=mufumbo"]) {
if (![self openURL:#"tweetie:///user?screen_name=mufumbo"]) {
[self openURL:#"http://twitter.com/mufumbo"];
}
}
}
you can include many more and make it a generic loop.

how do I open iphone apps via phonegap

I want to open iphone apps like Contacts and Calendar from within my phonegap app, I don't mind that doing so will put my app in the background. I can open the browser and using window.open but how do I open other apps?
eg window.open("contacts://", '_blank'); doesn't work
The only way that one app, PhoneGap-based or otherwise, can cause another app to launch is to open an URL that uses the target app's custom URL scheme. So, if the Contacts app supports some custom scheme, you're in luck. If not, you're out of luck.
You are going to need to write a custom phonegap plugin so that you can access custom methods you write in objective C.
The official phonegap documentation is here.
I'll briefly explain how you will do this.
In your javascript you will call this code :
PhoneGap.exec("OpenMailAppPlugin.openMailApp",parameter1);
In objective C you will create a new file OpenMailAppPlugin class. Read the link above for exact instuctions, but the important method will be soemthing like this.
-(void) openMailApp:(NSMutableArray*)paramArray withDict:(NSMutableDictionary*)options {
NSString *parameter1 = [paramArray objectAtIndex:0]; //recieves information from javascript function
NSURL* mailURL = [NSURL URLWithString: #"mailto:%#?cc=bar#example.com&subject=Greetings%20from%Cupertino!&body=Wish%20you%20were%20here!",paramter1];
[[UIApplication sharedApplication] openURL: mailURL];
}
additionally, you may be interested in sending information back to your phonegap application. You can do this by injecting a javascript call that sends parameters. In your objective C function you would do something like this.
NSString * jsCallBack = [NSString stringWithFormat:#"myJavascriptFunction('%#');",parameter];
[self.webView stringByEvaluatingJavaScriptFromString:jsCallBack];
As previously answered, using a URL scheme can work. If you have several apps and you want to be able to open one from the other, then it's really simple when using PhoneGap build: you just need to add the URL scheme to your config.xml file, eg:
// In config.xml
<gap:url-scheme>
<scheme>app1scheme</scheme>
</gap:url-scheme>
Then from your other app you'll just have a link to app1scheme://, eg simply
Start App1
Here is the list of all the iOS/iPhone app url
Video - video:
Music - music:
Youtube - youtube.com
iTunes store - itms:
iBooks - itms-books:
App Store - itms-apps:
Mail sending - mailto:
Telephone - tel:
More can be found at this outdated link
http://www.wiki.akosma.com/IPhone_URL_Schemes
Look at this on how you can implement your's url
https://appurl.org/docs-handling-android
Need to use a plugin, unfortunately you need native ios code:
This one works:
https://github.com/phonegap/phonegap-plugins/tree/master/iOS/ExternalFileUtil

Rate my Application in iTunes within my Application in iPhone

I have to provide a link in my app where the user touches on it it will take me to the itunes Appstore page of my application where the user can rate the Application. I think other apps try to access the Appstore Application in the device and pass the corresponding url of the application in itunes... How to do this? Any ideas...
Here's my method; this goes straight to the App Store and to the Review/Rate page for my app:
- (IBAction)rateGame {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=409954448"]];
}
Just change the id at the end (409954448) to the id for your app. Also, if you track the launch count or something, you can trigger this method after, say 12 launches to increase ratings. I added this in my update and in about 2 weeks it generated 5 ratings. Very useful.
NSURL* urlToMyApp = #"http://url.to.my/app/in/the/app/store";
[[UIApplication sharedApplication] openURL:urlToMyApp];
You can also use,
See link below, It will redirect you on app store app details page.
StoreKit.framework not needed.
http://www.brianjcoleman.com/tutorial-how-to-add-write-a-review-rate-us-feature-to-your-app/
Notes :
If iOS >= 7 use, [[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:#"itms-apps://itunes.apple.com/app/idYOUR_APP_ID"]]];
This will not work on simulator so don't test on Simulator :-)

Help me to run a iPhone application

I am going to develop a iPhone application.
In that i need to run another iPhone app when the user clicks on the button.
Is it possible to run a iPhone app from another iPhone app?
If possible, Please let me know your inputs on this.
Thanks for any help.
[copy and paste of a previous answer I gave here for the click-averse]
You can use the url scheme built into iOS. For example, you could call Safari with a url because it is registered as the application which handles the http URL scheme
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://www.google.com/"]]
The openURL: method is an instance method of the singleton UIApplication instance, on which you can call any application installed which registers in its plist an ability to handle some sort of input data.
Here's a list of common url schemes in iOS.
A little known way to detect the existence of another application on a device is to use canOpenURL: on the same singleton instance:
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"cydia://"]])
{
NSLog(#"cydia installed");
}
else
{
NSLog(#"cydia not installed");
}
Only if that other app is already installed and run and has been designed to register a custom URL handler to itself with the OS.
The your app can run it by using that custom URL scheme.
If the app has a custom URL Schema and you know what it is, then it is possible to launch another app form yours.
When user pressed the button, your current app will close and run the new app..
Yea.. Its possible.. BUT you must know the "short link" of the other app.. I tried it before and even successfully transferred data from the lite version to the full version..
Its called url scheme..
Here's a link:
http://www.idev101.com/code/Objective-C/custom_url_schemes.html
Hope it can achieve what you want..