I have followed exactly the same tutorial Launch an app from within another (iPhone) but the code is only executing the else part and showing alert, So I am unable to open the second app. You can see the steps I have followed in the link above.
Let's assume that we have two apps called FirstApp and SecondApp. When we open the FirstApp, we want to be able to open the SecondApp by clicking a button. The solution to do this is:
In SecondApp
Go to the plist file of SecondApp and you need to add a URL Schemes with a string iOSDevTips(of course you can write another string.it's up to you).
2 . In FirstApp
Create a button with the below action:
- (void)buttonPressed:(UIButton *)button
{
NSString *customURL = #"iOSDevTips://";
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];
}
}
Add the custom Url in info.plist
1st image - In Your App which you are opening
2nd Image - In Your App which from you are opening
For full explanation and code visit my blog here
Related
In my Application when i log in, after that Home screen will load at that time in my ViewDidLoad method of Home screen check that location service is ON or not . If it is not turn on then it will appear Error Screen.
Above functionality work fine but after that user immediately go to the setting of their cell , turn ON location service and again tap on application that is running in background will load Home screen and hide Error Screen.
if([CLLocationManager locationServicesEnabled]==YES)
{
NSLog(#"Location Services Enabled");
if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"App Permission Denied"
message:#"To re-enable, please go to Settings and turn on Location Service for this app."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
[LocationGuideview setHidden:NO];
}
}
so please tell me how its possible ?????????
What you can try here is add the above code in the application delegate.m file in the applicationDidEnterForeGround and maintain a flag in the plist or user default which you can access across your project
Your code would be something like this then
- (void)applicationWillEnterForeground:(UIApplication *)application
{
//check for location service
if([CLLocationManager locationServicesEnabled]==YES)
{
NSLog(#"Location Services Enabled");
// store a value in plist or user default for further reading set it to YES or whatever you like
}else{
// Location services are not enabled set NO as flag value
}
}
Then inside your view controller in the view did load or view will appear you can read the stored value and do your stuff.
If you are using user defaults please use the synchronize method.
I have created a password protected app. The app is allowed to run in background.
When it returns to foreground, I display an alert to prompt the user for password, by overriding the applicationWillEnterForeground: method in appdelegate like so-
- (void)applicationWillEnterForeground:(UIApplication *)application
{
if (/*password is enabled*/) {
alertview = [[UIAlertView alloc] initWithTitle:#"LOGIN"
message:#"Enter app password"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
alertview.alertViewStyle = UIAlertViewStyleSecureTextInput;
pwdTF = [alertview textFieldAtIndex:0];
[pwdTF setDelegate:self];
[alertview show];
}
}
However, the alert takes a little time to appear. During this time, the view remains vulnerable.
Is there a way to make uialertview show instantly?
dispatch_async(dispatch_get_main_queue(), ^{
<# Write UI related code to be executed on main queue #>
});
This question already has answers here:
iOS stopped asking user for Photo Library Permission
(6 answers)
Closed 8 years ago.
I've an iphone app where the user is able to upload photos. During test on ios simulator, everytime I click the "upload image" button, the simulator pops up an alert that says I should give the app permission to access photo albums.
The problem is that the simulator never asked me before if I want to give it access or not. And when I go to privacy settings on the simulator -> photos, I do no see the app to toggle it ON!
I tried resetting content & settings of the simulator, but that didn't solve the problem.
I'm using xCode 5.0.2
Simulator 7.0 iOS 6.1 simulator component
did you check Settings->Privacy->Photos? you should allow your app have full access here.
add following code to somewhere
UIImagePickerController* picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:Nil];
remember to add this function to handle picked image
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissViewControllerAnimated:YES completion:nil];
}
try this then to see what happened on your machine.
I found the problem
There is code
if (status != ALAuthorizationStatusAuthorized) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Alert" message:#"Please give the app access to photo album" delegate:nil cancelButtonTitle:#"Close" otherButtonTitles:nil, nil];
[alert show]; }
I changed:
if (status != ALAuthorizationStatusAuthorized) {
to
if (status == ALAuthorizationStatusDenied) {
Then it worked and asked me for permission, accepted it, and everything is ok now
Thanks everyone
I'm currently using a UIDocumentInteractionController for open in functionality. When it opens it shows a list of all apps on the device that can handle that file type.
Is there a way to disable my app sending a document to specific apps, even if they support that file type? For example - if I have a PDF file open in my app and iBooks is on the iPad, if I tap the iBooks icon in the UIDocumentInteractionController, I don't want it to send it to the app.
Ideally - I see this as building a blacklist (or whitelist). For example, it would be great to do this:
- (void) documentInteractionController: (UIDocumentInteractionController *) controller willBeginSendingToApplication: (NSString *) application {
// if app is blacklisted
if ([application isEqualToString:#"com.schimera.WebDAVNavigator"]) {
[self.interactionController dismissMenuAnimated:YES];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"FAIL" message:#"NO" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
return
}
}
With this however, the document is still sent to the application even if it is "black listed".
Is this approach at all possible?
Cheers!
Change the UIDocumentInteractionController's URL to an invalid value if the app is blacklisted. In the method -[UIDocumentInteractionControllerDelegate documentInteractionController: willBeginSendingToApplication:].
-(void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application
{
if([application isEqualToString:#"com.evilcorp.badapp"){
controller.URL = nil;
}
}
To offer open file in a specific app (as white list), just add (using swift 3.0):
docController.uti = #"com.yourapp.package";
I have created a tab in my app, where the user could call the client directly from within the app.
But I wont show his number, i want to display: "Do you want to call Client?" instead of "Do you want to call 000-000-000"
I've seen this solution in another app, but dont have a clue how to do this.
The openURL call does not automatically prompt the user for anything.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:7205551212"]];
It's good practice to confirm with the user, but it's up to you to determine the message. To show the alert, do something like this:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"Confirmation" message:#"Do you want to call Client?" delegate:self cancelButtonTitle:#"No" otherButtonTitles:#"Yes", nil];
[alertView show];
[alertView release];
Then make the actual phone call in a UIAlertViewDelegate method:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:7205551212"]];
}
}