Add APNs option to notification settings screen as well

This commit is contained in:
nielsandriesse 2020-04-14 16:57:32 +10:00
parent 5c5b28e0d9
commit 026bb4aa45
3 changed files with 30 additions and 0 deletions

View File

@ -87,6 +87,12 @@ final class PNModeVC : BaseVC, OptionViewDelegate {
}
@objc private func register() {
guard selectedOptionView != nil else {
let title = NSLocalizedString("Please Pick an Option", comment: "")
let alert = UIAlertController(title: title, message: nil, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: ""), style: .default, handler: nil))
return present(alert, animated: true, completion: nil)
}
UserDefaults.standard[.isUsingFullAPNs] = (selectedOptionView == apnsOptionView)
TSAccountManager.sharedInstance().didRegister()
let homeVC = HomeVC()

View File

@ -62,6 +62,21 @@
OWSPreferences *prefs = Environment.shared.preferences;
OWSTableSection *strategySection = [OWSTableSection new];
strategySection.headerTitle = NSLocalizedString(@"Notification Strategy", @"");
[strategySection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"Use APNs", @"")
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"notification_strategy")
isOnBlock:^{
return [NSUserDefaults.standardUserDefaults boolForKey:@"isUsingFullAPNs"];
}
isEnabledBlock:^{
return YES;
}
target:weakSelf
selector:@selector(didToggleAPNsSwitch:)]];
strategySection.footerTitle = NSLocalizedString(@"The app will use the Apple Push Notification Service. You'll be notified of new messages immediately. This mode entails a slight privacy sacrifice as Apple will know your IP. The contents of your messages will still be fully encrypted, your data will still be stored in a decentralized manner and your messages will still be onion routed.", @"");
[contents addSection:strategySection];
// Sounds section.
OWSTableSection *soundsSection = [OWSTableSection new];
@ -119,4 +134,9 @@
[Environment.shared.preferences setSoundInForeground:sender.on];
}
- (void)didToggleAPNsSwitch:(UISwitch *)sender
{
[NSUserDefaults.standardUserDefaults setBool:sender.on forKey:@"isUsingFullAPNs"];
}
@end

View File

@ -2809,3 +2809,7 @@
"Join Public Chat" = "Join Public Chat";
"No, thank you" = "No, thank you";
"Report" = "Report";
"Please Pick an Option" = "Please Pick an Option";
"Notification Strategy" = "Notification Strategy";
"Use APNs" = "Use APNs";
"The app will use the Apple Push Notification Service. You'll be notified of new messages immediately. This mode entails a slight privacy sacrifice as Apple will know your IP. The contents of your messages will still be fully encrypted, your data will still be stored in a decentralized manner and your messages will still be onion routed." = "The app will use the Apple Push Notification Service. You'll be notified of new messages immediately. This mode entails a slight privacy sacrifice as Apple will know your IP. The contents of your messages will still be fully encrypted, your data will still be stored in a decentralized manner and your messages will still be onion routed.";