I am working in a Automation project. While using Location Service,It is showing an alert. Here alert message is do you want to use Location Service with OK and Cancel button. Now I don't want to click cancel or Ok button manually.I just want to get system alert programmatically and and handle the button click.I am using iOS 8 device.Is it possible?
Asked
Active
Viewed 300 times
2 Answers
1
use the time interval for this concept
[self.locationManager startUpdatingLocation];
// after that add the following line
[NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(cancelAlertinAutomatically:) userInfo:nil repeats:NO];
-(void)cancelAlertinAutomatically:(id)sender
{
NSLog(@"alert View is cancelled here");
[alert dismissWithClickedButtonIndex:0 animated:YES];
}

Anbu.Karthik
- 82,064
- 23
- 174
- 143
-
This is a generic question.If I'll use CoreBluetooth framework,during central and peripheral coonnection,It is also showing one alert.The message is "Do you want to Pair" with Cancel and Pair button.Now I want to handle Cancel and Pair button click. – Babuli Sep 03 '15 at 08:48
-
-
you want to get object in which button in click can you give some example for --> How do I get alert object? – Anbu.Karthik Sep 03 '15 at 08:55
-
Only I'll call [alert dismissWithClickedButtonIndex:0 animated:YES]; If and only if I have alert object.Here the question is to get system AlertView or AlertController object first. – Babuli Sep 03 '15 at 09:12
-
yes correct, [alert dismissWithClickedButtonIndex:0 animated:YES]; --> Allow [alert dismissWithClickedButtonIndex:1 animated:YES]; --> Don't allow, ya initially you need to get system alert first , thats why I added the time interval in after 4 sec – Anbu.Karthik Sep 03 '15 at 09:18
-
Thanks.Do you have any idea to get System alert object ? I tried with UIWindow *window = [[UIApplication sharedApplication] keyWindow]; and UIWindow *window = [[UIApplication sharedApplication] windows]; to get the alert window.But it's not working. – Babuli Sep 03 '15 at 09:22
-
see this link http://stackoverflow.com/questions/3782066/how-to-get-my-uiwindow-using-uiapplication , you can get the windows, if answer is fine please upvote the answer it is useful for future – Anbu.Karthik Sep 03 '15 at 09:23
0
XCode has tons of automation features, appium or similar ones can take advantage of this and you can do automation. This could be your search point where you can achieve this

mkumar
- 111
- 1
- 10