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
Related
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];
}
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.
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
Im trying to put in a rate App alert, but its not opening properly, in fact when I click the Yes button it dosnt open the url at all, How do I make it work?
Below is the call in the viewdidload:
The below code in viewdidload is also in app delegate
[super viewDidLoad];
//rate app
NSUserDefaults *prefsr = [NSUserDefaults standardUserDefaults];
NSInteger launchCount = [prefsr integerForKey:#"launchCount"];
if (launchCount >= 1) {
UIAlertView *alertRate = [[UIAlertView alloc] initWithTitle:#"Like this app?" message:#"Rate on the app store." delegate:nil cancelButtonTitle:#"No, thanks" otherButtonTitles:#"Yes",#"Remind me later", nil];
[alertRate show];
}
-(void)alertViewRate:(UIAlertView *)alertViewRate clickedButtonAtIndex:(NSInteger)buttonIndexP{
if (buttonIndexP == 2) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"https://www.google.com"]];
}
else if (buttonIndexP == 1){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"https://www.google.com"]];
}
Add the delegate Self while creating the UIAlertView
UIAlertView *alertRate = [[UIAlertView alloc] initWithTitle:#"Like this app?" message:#"Rate on the app store." delegate:self cancelButtonTitle:#"No, thanks" otherButtonTitles:#"Yes",#"Remind me later", nil];
[alertRate show];
Delegate method for UIAlertView also need to be chnaged
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 2) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"https://www.google.com"]];
}
else if (buttonIndex == 1){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"https://www.google.com"]];
}
}
You haven't set the delegate to self while you are creating UIAlertView object. So -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex method is not getting called when you click on buttons in the AlertView.
Change your code From
UIAlertView *alertRate = [[UIAlertView alloc] initWithTitle:#"Like this app?" message:#"Rate on the app store." delegate:nil cancelButtonTitle:#"No, thanks" otherButtonTitles:#"Yes",#"Remind me later", nil];
To
UIAlertView *alertRate = [[UIAlertView alloc] initWithTitle:#"Like this app?" message:#"Rate on the app store." delegate:self. cancelButtonTitle:#"No, thanks" otherButtonTitles:#"Yes",#"Remind me later", nil];
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.