Calling an app from within my app does not work - ios

I have the following code:
NSString *customURL = #"photo://";
NSURL *url = [NSURL URLWithString:customURL];
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:customURL]])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"URL error"
message:[NSString stringWithFormat:#"No custom URL defined for %#", customURL]
delegate:self cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
}
Which is trying to open iPhoto app by using the custom URL. But the code returns error message and iPhoto is not launched. Any idea why this is?
Thank you for your help.

photo:// doesn't seem to be a supported url.
https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007899-CH1-SW1

Related

What is the scheme for calculator?

I'm trying to open the app "Calculator" but I don't know the Scheme
- (IBAction)btnColetorClick:(id)sender
{
NSString *customURL = #"calculator://";
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:customURL]])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"URL error"
message:[NSString stringWithFormat:#"No custom URL defined for %#", customURL]
delegate:self
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
}
}
It seems that there is no scheme for the native calculator.
Related:
api for showing native calculator in iOS app
Launch an app from within another (iPhone)
You can try "calc://"
it works on iOS13

open Whats app from iOS application and handle cancel click in iOS?

In my application having sharing text on whatsapp... and when cancel from whatsapp its back to original ios app ..
i don't know how to handle cancel click of whatsapp in ios ..
please resolved my problem ..
i used below code for sharing text...
NSString * msg = #"YOUR MSG";
NSString * urlWhats = [NSString stringWithFormat:#"whatsapp://send?text=%#",msg];
NSURL * whatsappURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
} else {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:#"WhatsApp not installed." message:#"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}

How to return back to app from Whatsapp

I tried using this method for sending message on whatsapp from my iOS app.
For text
NSString * msg = #"YOUR MSG";
NSString * urlWhats = [NSString stringWithFormat:#"whatsapp://send?text=%#",msg];
NSURL * whatsappURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}
else {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:#"WhatsApp not installed." message:#"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
I have 2 questions.
1.) how to get back to the app from Whatsapp.
2.) How to send message or image etc by entering phone number instead of fetching from contacts list.

How to add another button that directs users to Facebook on uiAlert?

I need to add a button Facebook, Then the action should take user to Facebook, I'm just not sure how to do it from the code below?
-(IBAction)btContinueClick:(id)sender{
if(Level == [list count]){
UIAlertView *info = [[UIAlertView alloc]initWithTitle:#"Good" message:#"Go to facebook?" delegate:self cancelButtonTitle:#"NO" otherButtonTitles:#"Facebook"];
[info show]; //// Change Game End Message
}
}
If you want to go to the native app of Facebook in iOS.
Using delegate method of alertView
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 1) {
NSURL *url = [NSURL URLWithString:#"fb://profile"];
if ([[UIApplication sharedApplication] canOpenURL:url]) { //USE FB NATIVE APP
[[UIApplication sharedApplication] openURL:url];
}
else { //IF THE DEVICE IS UNABLE TO OPEN IN NATIVE APP, USE BROWSER INSTEAD
NSURL *browserURL = [NSURL URLWithString:#"http://www.facebook.com"];
[[UIApplication sharedApplication] openURL:browserURL];
}
}
}
Make sure you have added UIAlertViewDelegate in .h file
-(IBAction)btContinueClick:(id)sender{
if(Level == [list count]){
UIAlertView *info = [[UIAlertView alloc]initWithTitle:#"Good" message:#"Go to facebook?" delegate:self cancelButtonTitle:#"NO" otherButtonTitles:#"Facebook"];
[info show]; //// Change Game End Message
info.delegate=self;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if(buttonIndex==1)
{
NSLog(#"Facebook selected.");
NSURL *url = [NSURL URLWithString:#"fb://profile/<id>"]; // provide the app ID
[[UIApplication sharedApplication] openURL:url];
}
}

End call method - iOS development

What's the method that gets called when the user press the end call button while making a phone call and how to use it in my app?
Thank you
Your app cannot end user's phone calls for them, just as it can't make phone calls.
If there were a method it would be part of CTCall. There isn't one.
You can make calls from within an app:
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"telprompt://<number>"]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"telprompt://<number>"]];
} else {
UIAlertView *av = [[UIAlertView alloc] initWithTitle:#"No Phone" message:#"" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[av show];
}
or
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"tel://<number>"]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel://<number>"]];
} else {
UIAlertView *av = [[UIAlertView alloc] initWithTitle:#"No Phone" message:#"" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[av show];
}
The first version will return you to your app and execute your callback function, the second won't. The first version will prompt you with an alert box to make the call, the second won't.

Resources