How to launch Health iOS app from another iOS APP - iphone

I am trying to launch Health app from my application.
I usually try with the following lines of code for launching application like as
let mystr = "health://"
let myurl = NSURL(string: mystr)!
if (UIApplication.sharedApplication().canOpenURL(myurl))
{
UIApplication.sharedApplication().openURL(myurl)
}
else
{
print("unable to open")
}
I tried above code.i am getting error ("null").
Some one please help in this issue.
Thanks in advance.

With iOS 10+ try this:
let mystr = "x-apple-health://"
Maybe in objective.c:
-(IBAction)openAppHealth:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"x-apple-health://"] options:#{} completionHandler:nil];
}
with new openURL for iOS 10
openURL: deprecated in iOS 10

You cannot open HealthApp directly from your app. Because OS is supporting only for opening the settings App using UIApplicationOpenSettingsURLString. If we use URL scheme to open the HealthApp, then Apple may reject the App in review process.

I don't have any experience with the HealthKit framework but here's what I found :
According to Open Apple Health programmatically you cannot create a deeplink from your app to the Health app because it is not supported.
If you'd wish to use the Health app's data you'll have to implement the HealthKit framework into your app and asks for permission to your users.
I tried to deeplink into the Health app using code that works for other apps and got the same results as you.

Related

Unable to open YouTube URL to be played on YouTube tvOS Application

Question:
How do I open a YouTube URL (from my tvOS Application) to the YouTube tvOS Application?
Description:
My url fits the youtube url scheme indicated by apple. The prints I get when I run this (on the actual apple tv device) is as follows:
"Can open shared application url."
"tvOS 10.0 detected"
"Result... false"
So for some reason it's telling me that I'm able to open the url, but then when I attempt to open it. Nothing happens (except for that last print ( see 3. above ))
let url = URL(string: "https://www.youtube.com/watch?v=smOp5aK-_h0")
if UIApplication.shared.canOpenURL(url){
print("Can open shared application url.")
if #available(tvOS 10.0, *) {
print("tvOS 10.0 detected")
UIApplication.shared.open(url){res in
print("Result..." + String(res))
}
} else {
// Fallback on earlier versions
UIApplication.shared.openURL(url)
}
}
Youtube URL Scheme:
Native app URL strings:
http://www.youtube.com/watch?v=VIDEO_IDENTIFIER
http://www.youtube.com/v/VIDEO_IDENTIFIER
Many tvOS devs would like to have an option to play YouTube content in their apps on the AppleTV, which is only possible through the YouTube app. It's up to Google to add support for URL schemes compatible with the ones available in the iOS version of the app and they don't seem motivated to make this extra effort.
While the methods do exist to open a URL in a shared application, it does not seem to be supported (by YouTube?) as of right now.
The best I was able to do was to open YouTube Apple Tv App, but it is unable to play the video I wanted.

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]];

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..

How To Check Installed Application On iPhone Device

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"])