How do I custom the alert view when making a phone call - ios

currently I'm using UIWebView to make phone calls
NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:#"tel://123456789"];
[self.callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
when I touch on a button to make call, an UIAlertView appears and ask for confirmation with title 123456789
How can I change its title and message ?
Thanks.

Don't use a UIWebView, just present a UIAlertView to the user asking if he/she want to call. Also there are no // in the tel: scheme, so tel:123456789 is correct.
Then just open open the tel: url via [[UIApplication sharedApplication] openURL:telURL].
Also do not forget the check whether the users device can make phone calls:
NSURL *telURL = [NSURL URLWithString:#"tel:123456789"];
if ([[UIApplication sharedApplication] canOpenURL:telURL]) {
// Present the user with the dialog to start the call
} else {
// inform the user that he/she can't call numbers from their device.
}

Related

Open system settings to Add New Keyboard

I know it is possible to open up your app's own settings:
if (&UIApplicationOpenSettingsURLString != NULL) {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
else {
// Present some dialog telling the user to open the settings app.
}
However, I need to open up a screen in the system settings. Specifically this one (the screen that contains the "Add New Keyboard" button, or even better, the screen right after that screen):
What do I need to do to implement this functionality in a button? (Answers in swift or objective-C are fine)

Is There a Way to Display a Specific User's Instagram Feed?

I'm creating a tabbed iOS application. I need one of the tabbed pages to only show the IG feed of a specific user (not the user who logs in). How do I go about doing so?
Edited: Ok, now I've registered my app via the IG Developer page, and I've gotten my client id. Now I need the user's profile to load up in my web view.
Here is my code in my InstaViewController.m file:
- (void)viewDidLoad
{
[super viewDidLoad];
UIActivityIndicatorView *activityView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityView.center=self.view.center;
[activityView startAnimating];
[self.view addSubview:activityView];
// Do any additional setup after loading the view.
NSURL *instagramURL = [NSURL URLWithString:#"instagram://user?username=MAMA_MIA"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
}
}
Using the following URI from the Instagram API, you can get any users feed if you know their user ID.
https://api.instagram.com/v1/users/{USER_ID}/media/recent/?client_id={CLIENT_ID}

UIApplication's -canOpenURL: -openURL: return misleading result

Since iOS6, I can't tell whether the application can launch Safari or not.
If Safari is restricted on the device (Settings>General>Restrictions), nothing happens when trying to open a URL, and there's no indication of what went wrong:
NSURL *url = [NSURL URLWithString:#"http://www.google.com"];
[[UIApplication sharedApplication] canOpenURL:url]; // Returns YES
[[UIApplication sharedApplication] openURL:url]; // Returns YES
However, Safari does not launch, and the user is left wondering why my buttons are "broken".
This seems like a bug to me so I filed a radar #12449905.
Is there another way to solve this problem?
If this is an Apple bug, then it looks like the thing for you to do is to program around it. Once the user clicks the button, you can always write something like this:
[self performSelector:#selector(notifyUserOfRestrictedAccess) withObject:self afterDelay:.5];
In the app delegate, you can set a property such as:
- (void)applicationWillResignActive:(UIApplication *)application {
self.openingExternalProgram = YES;
}
In your view controller, create the method like this:
-(void) notifyUserOfRestrictedAccess {
if (!appDelegate.openingExternalProgram) {
// Message the user via UIAlertView about restricted Safari access
}
appDelegate.openingExternalProgram = NO;
}
I'm sure there are better ways, but at least you don't have to wait on Apple.

iOS6/UIWebview redirecting to wrong page of App

Our app relies on UIWebview to return to the app following a phone call initiated by the user. After consulting a number of developers, we did not make any changes for iOS6, expecting the app to work fine.
Now, the following has happened:
1) UIWebview IS still working - bringing the user back into the app when they end a call
2) However, the app is directing the user to the wrong screen - it is taking it to the screen FOLLOWING the one the user should see. The crucial screen where the user can log their phone call is not showing up.
3) The only exception seems to be when the user logs out and logs back in - in this case they can see the correct screen ONLY once, and then the next time they call they go to the wrong screen again.
I am not a coder but after looking through the code as it stands, it looks like this is one of three (nearly identical) snippets of code that should be calling the End Call screen at the end of a phone call but under iOS6 is not:
- (IBAction)onCall:(id)sender
{
DashCaller *caller = [[DashCaller alloc] init];
NSString *callNumber = _phone.number;
if (!callNumber)
{
callNumber = #"No Phone number";
}
else if (callNumber.length == 0)
{
callNumber = #"No Phone number";
}
else
{
callNumber = [callNumber stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
}
DashDelegate.calledPhone = _phone;
DashDelegate.callLogVC.delegate = _viewController;
DashDelegate.callStartDate = [NSDate date];
NSUserDefaults *setting = [NSUserDefaults standardUserDefaults];
NSNumber *blockNumber = [setting valueForKey:BLOCK_NUMBER];
NSURL *url = nil;
if (blockNumber.boolValue)
url = [NSURL URLWithString:[NSString stringWithFormat:#"tel://%#%#", kStringBlockNumber, callNumber]];
else {
url = [NSURL URLWithString:[NSString stringWithFormat:#"tel://%#", callNumber]];
}
[caller callTelURL:url];
}
Specifically, the line "DashDelegate.callLogVC.delegate = _viewController;" seems like it should be calling the CallLogVC view but instead it is going to the screen that should appear right after that view.
Anyone with thoughts on what to change (that could have been affected by iOS6)? The app is fully functional in iOS5. And, why might the app show this page only once after a log-out-log-in and then stop showing it?
To go back to original app you can use telprompt:// instead of tel:// - The tell prompt will prompt the user first, but when the call is finished it will go back to your app:
NSString *phoneNumber = [#"telprompt://" stringByAppendingString:mymobileNO.titleLabel.text];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
You may also try these app delegate methods for restoring application after the call finishes.
- (void)applicationDidBecomeActive:(UIApplication *)application;
- (BOOL) application:(UIApplication *)application shouldSaveApplicationState:(NSCoder *)coder NS_AVAILABLE_IOS(6_0);
- (BOOL) application:(UIApplication *)application shouldRestoreApplicationState:(NSCoder *)coder NS_AVAILABLE_IOS(6_0);

Opening Phone app using button title

I have a UIButton with a telephone number as a title.
Will this code open the phone app with the title number?
- (IBAction)callContact:(id)sender
{
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:telfButton.titleLabel.text]];
}
It is giving me an error.
Depends what the URL is.
If its just 3033749943 it won't work. But tel://3033749943 will work just fine.
As stated in the other answer you have to use "tel://" to launch the phone app and dial the number. However, you can use NSString's stringWithFormat to add the number in the buttons title after "tel://".
- (IBAction)callContact:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel://%#",telfButton.titleLabel.text]];
}

Resources