mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-30 16:22:39 +00:00
Make the push notifications switch work. Also document the API call.
This commit is contained in:
parent
a7a8d29f71
commit
6868f7383f
2 changed files with 8 additions and 3 deletions
|
@ -122,16 +122,19 @@ static APNSHandler *sharedHandler = nil;
|
|||
NSLog(@"Using existing instance handle: %@", instanceHandle);
|
||||
}
|
||||
|
||||
NSObject *kind = isActive ? @"http" : [NSNull null];
|
||||
|
||||
MXRestClient *restCli = [MatrixSDKHandler sharedHandler].mxRestClient;
|
||||
[restCli setPusherWithPushkey:b64Token kind:@"http" appId:@"org.matrix.matrixConsole.ios" appDisplayName:@"Matrix Console iOS" deviceDisplayName:[[UIDevice currentDevice] name] instanceHandle:instanceHandle lang:deviceLang data:pushData success:^{
|
||||
[restCli setPusherWithPushkey:b64Token kind:kind appId:@"org.matrix.matrixConsole.ios" appDisplayName:@"Matrix Console iOS" deviceDisplayName:[[UIDevice currentDevice] name] instanceHandle:instanceHandle lang:deviceLang data:pushData success:^{
|
||||
[[NSUserDefaults standardUserDefaults] setBool:transientActivity forKey:@"apnsIsActive"];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kAPNSHandlerHasBeenUpdated object:nil];
|
||||
} failure:^(NSError *error) {
|
||||
NSLog(@"Failed to send APNS token!");
|
||||
}];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kAPNSHandlerHasBeenUpdated object:nil];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kAPNSHandlerHasBeenUpdated object:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -210,6 +210,7 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
|
|||
#pragma mark - Internal methods
|
||||
|
||||
- (void)onAPNSHandlerHasBeenUpdated {
|
||||
apnsNotificationsSwitch.enabled = YES;
|
||||
// Force table reload to update notifications section
|
||||
apnsNotificationsSwitch = nil;
|
||||
[self.tableView reloadData];
|
||||
|
@ -691,6 +692,7 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl
|
|||
}];
|
||||
} else if (sender == apnsNotificationsSwitch) {
|
||||
[APNSHandler sharedHandler].isActive = apnsNotificationsSwitch.on;
|
||||
apnsNotificationsSwitch.enabled = NO;
|
||||
} else if (sender == inAppNotificationsSwitch) {
|
||||
[AppSettings sharedSettings].enableInAppNotifications = inAppNotificationsSwitch.on;
|
||||
[self.tableView reloadData];
|
||||
|
|
Loading…
Reference in a new issue