Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/notifications.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-11-21 14:31:42 +0300
committerJoas Schilling <coding@schilljs.com>2017-11-21 16:30:03 +0300
commitbe535a7d8ac8cec4e41016ea91697a0166fa68c4 (patch)
tree8cc48fce58ca6983c651ac0a42b1db27b12c50fd /lib
parenteb42d13b867dd764d8cca5cd03791858f8c807ec (diff)
Only send Talk notificiations to the Talk app and vice-versa
Because iOS can not kill unrelated push notifications, we only send Talk notificaitons to the Talk app. We also don't send Talk notifications to the Sync app anymore, when you have at least one Talk app registered for push notifications. Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Push.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/Push.php b/lib/Push.php
index 30b7763..b4a60b0 100644
--- a/lib/Push.php
+++ b/lib/Push.php
@@ -89,8 +89,30 @@ class Push {
$userKey = $this->keyManager->getKey($user);
+ $isTalkNotification = in_array($notification->getApp(), ['spreed', 'talk'], true)
+ && in_array($notification->getSubject(), ['invitation', 'call'], true);
+ $talkApps = array_filter($devices, function($device) {
+ return $device['apptype'] === 'talk';
+ });
+ $hasTalkApps = !empty($talkApps);
+
$pushNotifications = [];
foreach ($devices as $device) {
+ if (!$isTalkNotification && $device['apptype'] === 'talk') {
+ // The iOS app can not kill notifications,
+ // therefor we should only send relevant notifications to the Talk
+ // app, so it does not pollute the notifications bar with useless
+ // notifications, especially when the Sync client app is also installed.
+ continue;
+ }
+ if ($isTalkNotification && $hasTalkApps && $device['apptype'] !== 'talk') {
+ // Similar to the previous case, we also don't send Talk notifications
+ // to the Sync client app, when there is a Talk app installed. We only
+ // do this, when you don't have a Talk app on your device, so you still
+ // get the push notification.
+ continue;
+ }
+
try {
$payload = json_encode($this->encryptAndSign($userKey, $device, $notification));