Skip to content

Commit

Permalink
removed UIAlertView from Simple Survey sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
John Bateman committed Oct 3, 2020
1 parent 33212c7 commit a17e33c
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions SimpleSurvey/Simple Survey/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//Set to Angry Birds 2 -- change to your app
#define APP_ID @"880047117"

@interface ViewController () <SMFeedbackDelegate, UIAlertViewDelegate>
@interface ViewController () <SMFeedbackDelegate>
@property (nonatomic, strong) SMFeedbackViewController * feedbackController;
@property (weak, nonatomic) IBOutlet UIButton *takeSurveyButton;
@property (weak, nonatomic) IBOutlet UILabel *statusLabel;
Expand Down Expand Up @@ -74,29 +74,38 @@ - (void)respondentDidEndSurvey:(SMRespondent *)respondent error:(NSError *) erro

}

#pragma mark - UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
}
else if(buttonIndex == 1)
{
NSString *appStoreURL = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@?mt=8", APP_ID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appStoreURL]];
}
}

- (void) showAlertWithBody:(NSString *)body hasRateButton:(BOOL)hasRateButton {
UIAlertView * alert =[[UIAlertView alloc ] initWithTitle:NSLocalizedString(@"Thanks for your feedback!", @"Heading for feedback prompt")
message:body
delegate:self
cancelButtonTitle: NSLocalizedString(@"Cancel", @"Title of cancel button on app store rating prompt")
otherButtonTitles: nil];

UIAlertController * alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Thanks for your feedback!", @"Heading for feedback prompt")
message:body
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* cancel = [UIAlertAction
actionWithTitle:NSLocalizedString(@"Cancel", @"Title of cancel button on app store rating prompt")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action)
{
// Respond to cancel button press.
}];

UIAlertAction* rate = [UIAlertAction
actionWithTitle:NSLocalizedString(@"Rate Us", @"Title of rate us button on app store rating prompt")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
// Respond to rate button press.
// (Note: This url will not open on a simulator. It must be run on a physical device.)
NSString *appStoreURL = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/apple-store/id%@", APP_ID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appStoreURL] options:@{} completionHandler:nil];
}];

[alertController addAction: cancel];

if (hasRateButton) {
[alert addButtonWithTitle:NSLocalizedString(@"Rate Us", @"Title of rate us button on app store rating prompt")];
[alertController addAction: rate];
}
[alert show];

[self presentViewController:alertController animated:YES completion:nil];
}

@end

0 comments on commit a17e33c

Please sign in to comment.