Settings: Prompt user when notifications are denied

This commit is contained in:
giomfo
2016-05-20 18:25:11 +02:00
parent fbcb082096
commit 3882b1f531
2 changed files with 25 additions and 2 deletions
+24 -2
View File
@@ -965,8 +965,30 @@
- (void)togglePushNotifications:(id)sender
{
// sanity check
if ([MXKAccountManager sharedManager].activeAccounts.count)
// Check first whether the user allow notification from device settings
if ([[MXKAccountManager sharedManager] isAPNSAvailable] == NO)
{
[currentAlert dismiss:NO];
__weak typeof(self) weakSelf = self;
currentAlert = [[MXKAlert alloc] initWithTitle:NSLocalizedStringFromTable(@"settings_on_denied_notification", @"Vector", nil)
message:nil
style:MXKAlertStyleAlert];
currentAlert.cancelButtonIndex = [currentAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert){
__strong __typeof(weakSelf)strongSelf = weakSelf;
strongSelf->currentAlert = nil;
}];
[currentAlert showInViewController:self];
// Keep off the switch
((UISwitch*)sender).on = NO;
}
else if ([MXKAccountManager sharedManager].activeAccounts.count)
{
[self startActivityIndicator];