Make the push notifications switch work. Also document the API call.

This commit is contained in:
David Baker 2015-01-29 17:06:37 +00:00
parent ba13533e8d
commit 7512cafa3b
2 changed files with 8 additions and 3 deletions

View file

@ -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

View file

@ -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];