Handle test notifications on iOS (#6002)

* Handle test notifications on iOS

* Update ios/Mattermost/AppDelegate.m

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>

* Update ios/Mattermost/AppDelegate.m

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>

* Fix indent

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
Daniel Espino García 2022-03-04 10:10:56 +01:00 committed by GitHub
parent 9dbdae22fd
commit d5ece8a4a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,7 @@
NSString* const NOTIFICATION_MESSAGE_ACTION = @"message";
NSString* const NOTIFICATION_CLEAR_ACTION = @"clear";
NSString* const NOTIFICATION_UPDATE_BADGE_ACTION = @"update_badge";
NSString* const NOTIFICATION_TEST_ACTION = @"test";
MattermostBucket* bucket = nil;
-(void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)(void))completionHandler {
@ -95,6 +96,12 @@ MattermostBucket* bucket = nil;
NSString* action = [userInfo objectForKey:@"type"];
NSString* channelId = [userInfo objectForKey:@"channel_id"];
BOOL isClearAction = (action && [action isEqualToString: NOTIFICATION_CLEAR_ACTION]);
BOOL isTestAction = (action && [action isEqualToString: NOTIFICATION_TEST_ACTION]);
if (isTestAction) {
completionHandler(UIBackgroundFetchResultNoData);
return;
}
if (isClearAction) {
// If received a notification that a channel was read, remove all notifications from that channel (only with app in foreground/background)