Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Add notificationBodyLocalizationKey to MXKAppSettings. #882

Merged
merged 5 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion MatrixKit/Models/Account/MXKAccount.m
Original file line number Diff line number Diff line change
Expand Up @@ -1241,10 +1241,12 @@ - (void)enableAPNSPusher:(BOOL)enabled success:(void (^)(void))success failure:(
NSString *appId = [[NSUserDefaults standardUserDefaults] objectForKey:@"pusherAppIdProd"];
#endif

NSString *locKey = MXKAppSettings.standardAppSettings.notificationBodyLocalizationKey;

NSDictionary *pushData = @{
@"url": self.pushGatewayURL,
@"format": @"event_id_only",
@"default_payload": @{@"aps": @{@"mutable-content": @(1), @"alert": @{@"loc-key": @"MESSAGE", @"loc-args": @[]}}}
@"default_payload": @{@"aps": @{@"mutable-content": @(1), @"alert": @{@"loc-key": locKey, @"loc-args": @[]}}}
};

[self enablePusher:enabled appId:appId token:[MXKAccountManager sharedManager].apnsDeviceToken pushData:pushData success:^{
Expand Down
13 changes: 12 additions & 1 deletion MatrixKit/Models/MXKAppSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,22 @@ typedef NS_ENUM(NSUInteger, MXKKeyPreSharingStrategy)
*/
@property (nonatomic) UIColor *presenceColorForOfflineUser;

#pragma mark - Push
#pragma mark - Notifications

/// Flag to allow PushKit pushers or not. Default value is `NO`.
@property (nonatomic, assign) BOOL allowPushKitPushers;

/**
A localization key used when registering the default notification payload.
This key will be translated and displayed for APNS notifications as the body
content, unless it is modified locally by a Notification Service Extension.

The default value for this setting is "MESSAGE". Changes are *not* persisted.
Updating the value after MXKAccount has called `enableAPNSPusher:success:failure:`
will have no effect.
*/
@property (nonatomic) NSString *notificationBodyLocalizationKey;

#pragma mark - Calls

/**
Expand Down
1 change: 1 addition & 0 deletions MatrixKit/Models/MXKAppSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ -(instancetype)init
httpsLinkScheme = @"https";

_allowPushKitPushers = NO;
_notificationBodyLocalizationKey = @"MESSAGE";
enableCallKit = YES;

eventsFilterForMessages = [NSMutableArray arrayWithArray:@[
Expand Down
1 change: 1 addition & 0 deletions changelog.d/4132.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Notifications: Add notificationBodyLocalizationKey to MXKAppSettings to customise the default notification payload.