Quellcode durchsuchen

#3821 Add option to include iBadgeCount in every push (performance, speed improvement)

Alex Trofimov vor 4 Jahren
Ursprung
Commit
102f70f1f7

+ 7 - 5
inc/classes/BxDolPush.php

@@ -131,9 +131,7 @@ class BxDolPush extends BxDolFactory implements iBxDolSingleton
             return false;
 
         if($bAddToQueue && BxDolQueuePush::getInstance()->add($iProfileId, $aMessage))
-            return true;
-
-        $iBadgeCount = $this->getNotificationsCount($iProfileId);
+            return true;        
     
 		$aFields = array(
 			'app_id' => $this->_sAppId,
@@ -145,10 +143,14 @@ class BxDolPush extends BxDolFactory implements iBxDolSingleton
             'web_url' => !empty($aMessage['url']) ? $aMessage['url'] : '',
             'data' => array('url' => !empty($aMessage['url']) ? $aMessage['url'] : ''),
             'chrome_web_icon' => !empty($aMessage['icon']) ? $aMessage['icon'] : '',
-            'ios_badgeType' => 'SetTo',
-            'ios_badgeCount' => $iBadgeCount,
 		);
 
+        if ('on' == getParam('bx_nexus_option_push_notifications_count')) {
+            $iBadgeCount = $this->getNotificationsCount($iProfileId);
+            $aFields['ios_badgeType'] = 'SetTo';
+            $aFields['ios_badgeCount'] = $iBadgeCount;
+        }
+
 		$oChannel = curl_init();
 		curl_setopt($oChannel, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
 		curl_setopt($oChannel, CURLOPT_HTTPHEADER, array(

+ 1 - 0
modules/boonex/nexus/install/langs/en.xml

@@ -11,6 +11,7 @@
     <string name="_bx_nexus_option_custom_homepage"><![CDATA[Display custom homepage with login form only]]></string>
     <string name="_bx_nexus_option_main_menu"><![CDATA[Main menu]]></string>
     <string name="_bx_nexus_option_main_menu_value"><![CDATA[{0}: {1}]]></string>
+    <string name="_bx_nexus_option_push_notifications_count"><![CDATA[Send number of notifications with each PUSH notification]]></string>
 
 	<string name="_bx_nexus_information"><![CDATA[Information]]></string>
     <string name="_bx_nexus_information_block"><![CDATA[This module adds neccesary styles and functionalty for proper functionality of UNA Nexus apps. Installing this module isn't enough, you need to get source code of mobile apps then modify them for your needs then publish in Google and Apple stores.]]></string>

+ 2 - 1
modules/boonex/nexus/install/sql/enable.sql

@@ -14,7 +14,8 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `e
 ('bx_nexus_option_styles', '', @iCategId, '_bx_nexus_option_styles', 'text', '', '', '', 10),
 ('bx_nexus_option_guest_pages', 'forgot-password,create-account,terms,privacy,contact,about,home', @iCategId, '_bx_nexus_option_guest_pages', 'text', '', '', '', 20),
 ('bx_nexus_option_custom_homepage', 'on', @iCategId, '_bx_nexus_option_custom_homepage', 'checkbox', '', '', '', 30),
-('bx_nexus_option_main_menu', 'default', @iCategId, '_bx_nexus_option_main_menu', 'select', 'a:3:{s:6:"module";s:8:"bx_nexus";s:6:"method";s:14:"get_menus_list";s:6:"params";a:0:{}}', '', '', 40);
+('bx_nexus_option_main_menu', 'default', @iCategId, '_bx_nexus_option_main_menu', 'select', 'a:3:{s:6:"module";s:8:"bx_nexus";s:6:"method";s:14:"get_menus_list";s:6:"params";a:0:{}}', '', '', 40),
+('bx_nexus_option_push_notifications_count', '', @iCategId, '_bx_nexus_option_push_notifications_count', 'checkbox', '', '', '', 50);
 
 -- Injections