-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from AgileBits/task/add-alert-to-email-for-bet…
…a-access Added alert so that developers can easily email us for beta access
- Loading branch information
Showing
2 changed files
with
61 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
} | ||
|
||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
} | ||
|
||
|
@@ -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 |