4
4
5
5
class PushPayload {
6
6
7
- private static $ EFFECTIVE_DEVICE_TYPES = array ('ios ' , 'android ' , 'winphone ' );
7
+ private static $ EFFECTIVE_DEVICE_TYPES = array ('ios ' , 'android ' , 'winphone ' , ' hmos ' );
8
8
9
9
private $ client ;
10
10
private $ url ;
@@ -25,6 +25,7 @@ class PushPayload {
25
25
private $ iosNotification ;
26
26
private $ androidNotification ;
27
27
private $ winPhoneNotification ;
28
+ private $ hmosNotification ;
28
29
private $ voip ;
29
30
private $ smsMessage ;
30
31
private $ message ;
@@ -52,7 +53,7 @@ public function setCid($cid) {
52
53
}
53
54
54
55
public function setPlatform ($ platform ) {
55
- # $required_keys = array('all', 'android', 'ios', 'winphone');
56
+ # $required_keys = array('all', 'android', 'ios', 'winphone', 'hmos' );
56
57
if (is_string ($ platform )) {
57
58
$ ptf = strtolower ($ platform );
58
59
if ('all ' === $ ptf ) {
@@ -287,6 +288,20 @@ public function build() {
287
288
}
288
289
}
289
290
291
+ if (!is_null ($ this ->hmosNotification )) {
292
+ $ notification ['hmos ' ] = $ this ->hmosNotification ;
293
+ if (is_null ($ this ->hmosNotification ['alert ' ])) {
294
+ if (is_null ($ this ->hmosNotification )) {
295
+ throw new InvalidArgumentException ("hmos alert can not be null " );
296
+ } else {
297
+ $ notification ['hmos ' ]['alert ' ] = $ this ->notificationAlert ;
298
+ }
299
+ }
300
+ if (is_null ($ this ->hmosNotification ['category ' ])) {
301
+ throw new InvalidArgumentException ("hmos category can not be null " );
302
+ }
303
+ }
304
+
290
305
if (!is_null ($ this ->voip )) {
291
306
$ notification ['voip ' ] = $ this ->voip ;
292
307
}
@@ -448,6 +463,50 @@ public function androidNotification($alert = '', array $notification = array())
448
463
return $ this ;
449
464
}
450
465
466
+ public function hmosNotification ($ alert = '' , $ category ='' , array $ notification = array ()) {
467
+ $ hmos = array ();
468
+ $ hmos ['alert ' ] = is_string ($ alert ) ? $ alert : '' ;
469
+ $ hmos ['category ' ] = is_string ($ category ) ? $ category : '' ;
470
+ if (!empty ($ notification )) {
471
+ if (isset ($ notification ['badge_add_num ' ])) {
472
+ if (is_int ($ notification ['badge_add_num ' ]) && $ notification ['badge_add_num ' ] >= 1 && $ notification ['badge_add_num ' ]<=99 ) {
473
+ $ hmos ['badge_add_num ' ] = $ notification ['badge_add_num ' ];
474
+ } else {
475
+ unset($ notification ['badge_add_num ' ]);
476
+ }
477
+ }
478
+ if (isset ($ notification ['test_message ' ])) {
479
+ if (is_bool ($ notification ['test_message ' ])) {
480
+ $ hmos ['test_message ' ] = $ notification ['test_message ' ];
481
+ } else {
482
+ unset($ notification ['test_message ' ]);
483
+ }
484
+ }
485
+ if (isset ($ notification ['intent ' ])) {
486
+ if (is_array ($ notification ['intent ' ]) && !empty ($ notification ['intent ' ])) {
487
+ $ hmos ['intent ' ] = $ notification ['intent ' ];
488
+ } else {
489
+ unset($ notification ['intent ' ]);
490
+ }
491
+ }
492
+ if (isset ($ notification ['extras ' ])) {
493
+ if (is_array ($ notification ['extras ' ]) && !empty ($ notification ['extras ' ])) {
494
+ $ hmos ['extras ' ] = $ notification ['extras ' ];
495
+ } else {
496
+ unset($ notification ['extras ' ]);
497
+ }
498
+ }
499
+ if ($ hmos ['category ' ] === '' && isset ($ notification ['category ' ])) {
500
+ if (is_string ($ notification ['category ' ]) && $ notification ['category ' ] !== '' ) {
501
+ $ hmos ['category ' ] = $ notification ['category ' ];
502
+ }
503
+ }
504
+ $ hmos = array_merge ($ notification , $ hmos );
505
+ }
506
+ $ this ->hmosNotification = $ hmos ;
507
+ return $ this ;
508
+ }
509
+
451
510
/**
452
511
* Voip in notification
453
512
* could add any custom key/value into it
0 commit comments