2
0

Harmonize consent flow on both platforms.

This commit is contained in:
Maarten Billemont 2020-04-21 11:33:31 -04:00
parent d4de3afb72
commit c4f60e325d
4 changed files with 99 additions and 51 deletions

View File

@ -22,6 +22,7 @@
@property(nonatomic, retain) NSNumber *sendInfo; @property(nonatomic, retain) NSNumber *sendInfo;
@property(nonatomic, retain) NSNumber *sendInfoDecided; @property(nonatomic, retain) NSNumber *sendInfoDecided;
@property(nonatomic, retain) NSNumber *notificationsDecided;
@property(nonatomic, retain) NSNumber *rememberLogin; @property(nonatomic, retain) NSNumber *rememberLogin;
@property(nonatomic, retain) NSNumber *hidePasswords; @property(nonatomic, retain) NSNumber *hidePasswords;

View File

@ -29,15 +29,16 @@
return nil; return nil;
[self.defaults registerDefaults:@{ [self.defaults registerDefaults:@{
NSStringFromSelector( @selector( sendInfo ) ) : @YES, NSStringFromSelector( @selector( sendInfo ) ) : @NO,
NSStringFromSelector( @selector( sendInfoDecided ) ) : @NO, NSStringFromSelector( @selector( sendInfoDecided ) ) : @NO,
NSStringFromSelector( @selector( notificationsDecided ) ): @NO,
NSStringFromSelector( @selector( rememberLogin ) ) : @NO, NSStringFromSelector( @selector( rememberLogin ) ) : @NO,
NSStringFromSelector( @selector( hidePasswords ) ) : @NO, NSStringFromSelector( @selector( hidePasswords ) ) : @NO,
NSStringFromSelector( @selector( siteAttacker ) ) : @(MPAttacker1), NSStringFromSelector( @selector( siteAttacker ) ) : @(MPAttacker1),
NSStringFromSelector( @selector( checkInconsistency ) ): @NO, NSStringFromSelector( @selector( checkInconsistency ) ) : @NO,
NSStringFromSelector( @selector( askForReviews ) ) : @YES, NSStringFromSelector( @selector( askForReviews ) ) : @YES,
}]; }];
self.delegate = [MPAppDelegate_Shared get]; self.delegate = [MPAppDelegate_Shared get];

View File

@ -29,7 +29,6 @@
#define LOGIN_HELPER_BUNDLE_ID @"com.lyndir.lhunath.MasterPassword.Mac.LoginHelper" #define LOGIN_HELPER_BUNDLE_ID @"com.lyndir.lhunath.MasterPassword.Mac.LoginHelper"
@implementation MPMacAppDelegate @implementation MPMacAppDelegate
#pragma clang diagnostic push #pragma clang diagnostic push
@ -134,7 +133,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
#if DEBUG #if DEBUG
countlyConfig.enableDebug = YES; countlyConfig.enableDebug = YES;
countlyConfig.pushTestMode = CLYPushTestModeDevelopment; countlyConfig.pushTestMode = CLYPushTestModeDevelopment;
#elif ! PUBLIC #elif !PUBLIC
countlyConfig.enableDebug = NO; countlyConfig.enableDebug = NO;
countlyConfig.pushTestMode = CLYPushTestModeTestFlightOrAdHoc; countlyConfig.pushTestMode = CLYPushTestModeTestFlightOrAdHoc;
#endif #endif
@ -205,7 +204,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
} }
[self enableNotifications]; [self tryNotifications];
} }
- (void)applicationWillResignActive:(NSNotification *)notification { - (void)applicationWillResignActive:(NSNotification *)notification {
@ -231,7 +230,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
return NSTerminateNow; return NSTerminateNow;
} }
- (void)enableNotifications { - (void)tryNotifications {
[Countly.sharedInstance giveConsentForFeature:CLYConsentPushNotifications]; [Countly.sharedInstance giveConsentForFeature:CLYConsentPushNotifications];
if (@available( macOS 10.14, * )) { if (@available( macOS 10.14, * )) {
@ -250,18 +249,19 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
- (void)askNotifications { - (void)askNotifications {
if ([[MPMacConfig get].notificationsDecided boolValue])
return;
PearlMainQueue( ^{ PearlMainQueue( ^{
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"notificationsDecided"]) { if (@available( macOS 10.14, * )) {
if (@available( macOS 10.14, * )) { [Countly.sharedInstance askForNotificationPermissionWithOptions:UNAuthorizationOptionAlert completionHandler:
[Countly.sharedInstance askForNotificationPermissionWithOptions:UNAuthorizationOptionAlert completionHandler: ^(BOOL granted, NSError *error) {
^(BOOL granted, NSError *error) { [MPMacConfig get].notificationsDecided = @(YES);
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"notificationsDecided"]; }];
}]; }
} else {
else { [Countly.sharedInstance askForNotificationPermission];
[Countly.sharedInstance askForNotificationPermission]; [MPMacConfig get].notificationsDecided = @(YES);
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"notificationsDecided"];
}
} }
} ); } );
} }
@ -440,8 +440,8 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
NSAlert *alert = [NSAlert new]; NSAlert *alert = [NSAlert new];
[alert setMessageText:@"New User"]; [alert setMessageText:@"New User"];
[alert setInformativeText:@"To begin, enter your full name.\n\n" [alert setInformativeText:@"To begin, enter your full name.\n\n"
@"IMPORTANT: Enter your name correctly, including the right capitalization, " @"IMPORTANT: Enter your name correctly, including the right capitalization, "
@"as you would on an official document."]; @"as you would on an official document."];
[alert addButtonWithTitle:@"Create User"]; [alert addButtonWithTitle:@"Create User"];
[alert addButtonWithTitle:@"Cancel"]; [alert addButtonWithTitle:@"Cancel"];
NSTextField *nameField = [[NSTextField alloc] initWithFrame:NSMakeRect( 0, 0, 200, 22 )]; NSTextField *nameField = [[NSTextField alloc] initWithFrame:NSMakeRect( 0, 0, 200, 22 )];
@ -769,8 +769,12 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
// Send info // Send info
NSArray *countlyFeatures = @[ NSArray *countlyFeatures = @[
CLYConsentSessions, CLYConsentEvents, CLYConsentUserDetails, CLYConsentCrashReporting, CLYConsentViewTracking, CLYConsentStarRating CLYConsentEvents, CLYConsentUserDetails, CLYConsentCrashReporting, CLYConsentViewTracking, CLYConsentStarRating
]; ];
if ([[MPConfig get].sendInfo boolValue] || ![[MPConfig get].sendInfoDecided boolValue])
[Countly.sharedInstance giveConsentForFeature:CLYConsentSessions];
else
[Countly.sharedInstance cancelConsentForFeature:CLYConsentSessions];
if ([[MPMacConfig get].sendInfo boolValue]) { if ([[MPMacConfig get].sendInfo boolValue]) {
if ([PearlLogger get].printLevel > PearlLogLevelInfo) if ([PearlLogger get].printLevel > PearlLogLevelInfo)
[PearlLogger get].printLevel = PearlLogLevelInfo; [PearlLogger get].printLevel = PearlLogLevelInfo;

View File

@ -176,7 +176,7 @@
if ([[MPiOSConfig get].showSetup boolValue]) if ([[MPiOSConfig get].showSetup boolValue])
[self.navigationController performSegueWithIdentifier:@"setup" sender:self]; [self.navigationController performSegueWithIdentifier:@"setup" sender:self];
[self enableNotifications]; [self consentFeatures];
} ); } );
} }
@catch (id exception) { @catch (id exception) {
@ -229,7 +229,44 @@
return YES; return YES;
} }
- (void)enableNotifications { - (void)consentFeatures {
if ([self askDiagnostics])
return;
[self tryNotifications];
}
- (BOOL)askDiagnostics {
if ([[MPiOSConfig get].sendInfoDecided boolValue])
return NO;
PearlMainQueue( ^{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Welcome to Master Password!" message:
@"We want this experience to be top-notch.\n\n"
@"We look for bugs, runtime issues, crashes & usage counters.\n"
@"Needless to say, diagnostics are always scrubbed and personal details will never leave your device."
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Disable" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
[MPiOSConfig get].sendInfo = @(NO);
[MPiOSConfig get].sendInfoDecided = @(YES);
[self consentFeatures];
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"Thanks" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[MPiOSConfig get].sendInfo = @(YES);
[MPiOSConfig get].sendInfoDecided = @(YES);
[self consentFeatures];
}]];
[(self.navigationController.presentedViewController?: (UIViewController *)self.navigationController)
presentViewController:alert animated:YES completion:nil];
} );
return YES;
}
- (void)tryNotifications {
[Countly.sharedInstance giveConsentForFeature:CLYConsentPushNotifications]; [Countly.sharedInstance giveConsentForFeature:CLYConsentPushNotifications];
if (@available( iOS 12, * )) { if (@available( iOS 12, * )) {
@ -240,35 +277,36 @@
[self askNotifications]; [self askNotifications];
}]; }];
return;
} }
else {
[self askNotifications]; [self askNotifications];
}
} }
- (void)askNotifications { - (void)askNotifications {
if ([[MPiOSConfig get].notificationsDecided boolValue])
return;
PearlMainQueue( ^{ PearlMainQueue( ^{
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"notificationsDecided"]) { UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Coming Soon" message:
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Coming Soon" message: @"Master Password is rolling out a new modern personal security platform and we're excited to bring you along.\n\n"
@"Master Password is rolling out a new modern personal security platform and we're excited to bring you along.\n\n" @"When it's time, we'll send you a notification to help you make an effortless transition."
@"When it's time, we'll send you a notification to help you make an effortless transition." preferredStyle:UIAlertControllerStyleAlert];
preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:@"Thanks" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[alert addAction:[UIAlertAction actionWithTitle:@"Thanks" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { if (@available( iOS 12, * )) {
if (@available( iOS 12, * )) { [Countly.sharedInstance askForNotificationPermissionWithOptions:UNAuthorizationOptionAlert completionHandler:
[Countly.sharedInstance askForNotificationPermissionWithOptions:UNAuthorizationOptionAlert completionHandler: ^(BOOL granted, NSError *error) {
^(BOOL granted, NSError *error) { [MPiOSConfig get].notificationsDecided = @(YES);
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"notificationsDecided"]; }];
}]; }
} else {
else { [Countly.sharedInstance askForNotificationPermission];
[Countly.sharedInstance askForNotificationPermission]; [MPiOSConfig get].notificationsDecided = @(YES);
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"notificationsDecided"]; }
} }]];
}]]; [(self.navigationController.presentedViewController?: (UIViewController *)self.navigationController)
[(self.navigationController.presentedViewController?: (UIViewController *)self.navigationController) presentViewController:alert animated:YES completion:nil];
presentViewController:alert animated:YES completion:nil];
}
} ); } );
} }
@ -643,8 +681,12 @@
// Send info // Send info
NSArray *countlyFeatures = @[ NSArray *countlyFeatures = @[
CLYConsentSessions, CLYConsentEvents, CLYConsentUserDetails, CLYConsentCrashReporting, CLYConsentViewTracking, CLYConsentStarRating CLYConsentEvents, CLYConsentUserDetails, CLYConsentCrashReporting, CLYConsentViewTracking, CLYConsentStarRating
]; ];
if ([[MPConfig get].sendInfo boolValue] || ![[MPConfig get].sendInfoDecided boolValue])
[Countly.sharedInstance giveConsentForFeature:CLYConsentSessions];
else
[Countly.sharedInstance cancelConsentForFeature:CLYConsentSessions];
if ([[MPConfig get].sendInfo boolValue]) { if ([[MPConfig get].sendInfo boolValue]) {
if ([PearlLogger get].printLevel > PearlLogLevelInfo) if ([PearlLogger get].printLevel > PearlLogLevelInfo)
[PearlLogger get].printLevel = PearlLogLevelInfo; [PearlLogger get].printLevel = PearlLogLevelInfo;