Skip to content

Commit

Permalink
Merge pull request #12 from AgileBits/task/add-alert-to-email-for-bet…
Browse files Browse the repository at this point in the history
…a-access

Added alert so that developers can easily email us for beta access
  • Loading branch information
roustem committed Jul 31, 2014
2 parents 5bb5585 + d9ebf5c commit c35cb75
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
32 changes: 30 additions & 2 deletions Demos/App Demo for iOS/App Demo for iOS/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@
//

#import "AppDelegate.h"
#import "OnePasswordExtension.h"

@interface AppDelegate ()
#import <MessageUI/MFMailComposeViewController.h>

@interface AppDelegate () <UIAlertViewDelegate, MFMailComposeViewControllerDelegate>

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
if (![[OnePasswordExtension sharedExtension] isAppExtensionAvailable]) {
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"1Password Beta is not installed" message:@"Email [email protected] for beta access" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Email", nil];
[alertView show];
}

return YES;
}

Expand All @@ -42,4 +49,25 @@ - (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

#pragma mark - UIAlertViewDelegate

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == alertView.firstOtherButtonIndex) {
MFMailComposeViewController* composeViewController = [[MFMailComposeViewController alloc] init];
composeViewController.mailComposeDelegate = self;
[composeViewController setToRecipients:@[ @"[email protected]" ]];
[composeViewController setSubject:@"App Extension"];

UIWindow *window = [UIApplication sharedApplication].windows.firstObject;
UIViewController *rootViewController = window.rootViewController;
[rootViewController presentViewController:composeViewController animated:YES completion:nil];
}
}

#pragma mark - MFMailComposeViewControllerDelegate

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
[controller dismissViewControllerAnimated:YES completion:nil];
}

@end
34 changes: 31 additions & 3 deletions Demos/WebView Demo for iOS/WebView Demo for iOS/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@
//

#import "AppDelegate.h"
#import "OnePasswordExtension.h"

@interface AppDelegate ()
#import <MessageUI/MFMailComposeViewController.h>

@interface AppDelegate () <UIAlertViewDelegate, MFMailComposeViewControllerDelegate>

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
if (![[OnePasswordExtension sharedExtension] isAppExtensionAvailable]) {
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"1Password Beta is not installed" message:@"Email [email protected] for beta access" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Email", nil];
[alertView show];
}

return YES;
}

Expand All @@ -42,4 +49,25 @@ - (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

#pragma mark - UIAlertViewDelegate

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == alertView.firstOtherButtonIndex) {
MFMailComposeViewController* composeViewController = [[MFMailComposeViewController alloc] init];
composeViewController.mailComposeDelegate = self;
[composeViewController setToRecipients:@[ @"[email protected]" ]];
[composeViewController setSubject:@"App Extension"];

UIWindow *window = [UIApplication sharedApplication].windows.firstObject;
UIViewController *rootViewController = window.rootViewController;
[rootViewController presentViewController:composeViewController animated:YES completion:nil];
}
}

#pragma mark - MFMailComposeViewControllerDelegate

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
[controller dismissViewControllerAnimated:YES completion:nil];
}

@end

0 comments on commit c35cb75

Please sign in to comment.