From 2d46566009246800e3690b7103f9f5aef259eb1a Mon Sep 17 00:00:00 2001 From: Doug Date: Thu, 15 Jul 2021 18:31:06 +0100 Subject: [PATCH 1/5] Relax behaviour of isAPNSAvailable and isPushAvailable to not worry about whether notifications will be show or simply delivered to notification centre. --- MatrixKit/Models/Account/MXKAccountManager.m | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/MatrixKit/Models/Account/MXKAccountManager.m b/MatrixKit/Models/Account/MXKAccountManager.m index 07c56981..45702ef4 100644 --- a/MatrixKit/Models/Account/MXKAccountManager.m +++ b/MatrixKit/Models/Account/MXKAccountManager.m @@ -428,19 +428,15 @@ - (void)setApnsDeviceToken:(NSData *)apnsDeviceToken - (BOOL)isAPNSAvailable { // [UIApplication isRegisteredForRemoteNotifications] tells whether your app can receive - // remote notifications or not. However receiving remote notifications does not mean it - // will also display them to the user. - // To check whether the user allowed or denied remote notification or in fact changed - // the notifications permissions later in iOS setting, we have to call - // [UIApplication currentUserNotificationSettings]. + // remote notifications or not. Receiving remote notifications does not mean it will + // also display them to the user as they may have notifications set to deliver quietly. BOOL isRemoteNotificationsAllowed = NO; UIApplication *sharedApplication = [UIApplication performSelector:@selector(sharedApplication)]; if (sharedApplication) { - UIUserNotificationSettings *settings = [sharedApplication currentUserNotificationSettings]; - isRemoteNotificationsAllowed = (settings.types != UIUserNotificationTypeNone); + isRemoteNotificationsAllowed = [sharedApplication isRegisteredForRemoteNotifications]; MXLogDebug(@"[MXKAccountManager][Push] isAPNSAvailable: The user %@ remote notification", (isRemoteNotificationsAllowed ? @"allowed" : @"denied")); } @@ -572,19 +568,15 @@ - (void)setPushDeviceToken:(NSData *)pushDeviceToken withPushOptions:(NSDictiona - (BOOL)isPushAvailable { // [UIApplication isRegisteredForRemoteNotifications] tells whether your app can receive - // remote notifications or not. However receiving remote notifications does not mean it - // will also display them to the user. - // To check whether the user allowed or denied remote notification or in fact changed - // the notifications permissions later in iOS setting, we have to call - // [UIApplication currentUserNotificationSettings]. + // remote notifications or not. Receiving remote notifications does not mean it will + // also display them to the user as they may have notifications set to deliver quietly. BOOL isRemoteNotificationsAllowed = NO; UIApplication *sharedApplication = [UIApplication performSelector:@selector(sharedApplication)]; if (sharedApplication) { - UIUserNotificationSettings *settings = [sharedApplication currentUserNotificationSettings]; - isRemoteNotificationsAllowed = (settings.types != UIUserNotificationTypeNone); + isRemoteNotificationsAllowed = [sharedApplication isRegisteredForRemoteNotifications]; MXLogDebug(@"[MXKAccountManager][Push] isPushAvailable: The user %@ remote notification", (isRemoteNotificationsAllowed ? @"allowed" : @"denied")); } From 9b4de3c8b58cde108db40ee4c98535b39fbb3bd9 Mon Sep 17 00:00:00 2001 From: Doug Date: Fri, 16 Jul 2021 10:34:52 +0100 Subject: [PATCH 2/5] Typo in doc comment. --- MatrixKit/Models/Account/MXKAccountManager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MatrixKit/Models/Account/MXKAccountManager.h b/MatrixKit/Models/Account/MXKAccountManager.h index 53c2240a..f86d9bce 100644 --- a/MatrixKit/Models/Account/MXKAccountManager.h +++ b/MatrixKit/Models/Account/MXKAccountManager.h @@ -70,7 +70,7 @@ extern NSString *const MXKAccountManagerDataType; @property (nonatomic, copy) NSData *apnsDeviceToken; /** - The APNS status: YES when app is registered for remote notif, and devive token is known. + The APNS status: YES when app is registered for remote notif, and device token is known. */ @property (nonatomic) BOOL isAPNSAvailable; From 08f83cd886d95dc29c66ce5888a6156163c94be5 Mon Sep 17 00:00:00 2001 From: Doug Date: Wed, 28 Jul 2021 12:00:15 +0100 Subject: [PATCH 3/5] Update comments. --- MatrixKit/Models/Account/MXKAccountManager.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MatrixKit/Models/Account/MXKAccountManager.m b/MatrixKit/Models/Account/MXKAccountManager.m index 45702ef4..35df98b0 100644 --- a/MatrixKit/Models/Account/MXKAccountManager.m +++ b/MatrixKit/Models/Account/MXKAccountManager.m @@ -428,8 +428,8 @@ - (void)setApnsDeviceToken:(NSData *)apnsDeviceToken - (BOOL)isAPNSAvailable { // [UIApplication isRegisteredForRemoteNotifications] tells whether your app can receive - // remote notifications or not. Receiving remote notifications does not mean it will - // also display them to the user as they may have notifications set to deliver quietly. + // remote notifications or not. Receiving remote notifications does not guarantee it will + // display them to the user as they may have notifications set to deliver quietly. BOOL isRemoteNotificationsAllowed = NO; @@ -568,8 +568,8 @@ - (void)setPushDeviceToken:(NSData *)pushDeviceToken withPushOptions:(NSDictiona - (BOOL)isPushAvailable { // [UIApplication isRegisteredForRemoteNotifications] tells whether your app can receive - // remote notifications or not. Receiving remote notifications does not mean it will - // also display them to the user as they may have notifications set to deliver quietly. + // remote notifications or not. Receiving remote notifications does not guarantee it will + // display them to the user as they may have notifications set to deliver quietly. BOOL isRemoteNotificationsAllowed = NO; From 5da3ff0644f767af32dae1aa644915ed888165a8 Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Thu, 29 Jul 2021 09:46:22 +0100 Subject: [PATCH 4/5] Update CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 9652e657..1ff98049 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,7 +12,7 @@ Changes to be released in next version * MXKRoomViewController: Fix initial timeline position when viewing a room for the second time. ⚠️ API Changes - * + * MXKAccountManager: `isAPNSAvailable` and `isPushAvailable` now only indicate the availability of notifications and not their visibility as well. 🗣 Translations * From 4f14bc8e13cf2a8e5cdfa78d76a0321411bf6eaf Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Thu, 29 Jul 2021 09:51:17 +0100 Subject: [PATCH 5/5] Update CHANGES.rst --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 1ff98049..90703ae1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,7 +12,7 @@ Changes to be released in next version * MXKRoomViewController: Fix initial timeline position when viewing a room for the second time. ⚠️ API Changes - * MXKAccountManager: `isAPNSAvailable` and `isPushAvailable` now only indicate the availability of notifications and not their visibility as well. + * MXKAccountManager: `isAPNSAvailable` and `isPushAvailable` now only indicate the availability of notifications and not their visibility as well (vector-im/element-ios/issues/2368). 🗣 Translations *