File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed
Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace Edujugon \PushNotification \Channels ;
44
5+ use Edujugon \PushNotification \Messages \PushMessage ;
6+
57class FcmV1Channel extends GcmChannel
68{
79 /**
@@ -11,4 +13,59 @@ protected function pushServiceName()
1113 {
1214 return 'fcmv1 ' ;
1315 }
16+
17+ /**
18+ * {@inheritdoc}
19+ */
20+ protected function buildData (PushMessage $ message )
21+ {
22+ $ data = [];
23+
24+ if ($ message ->title != null || $ message ->body != null ) {
25+ $ data = [
26+ 'notification ' => [
27+ 'title ' => $ message ->title ,
28+ 'body ' => $ message ->body ,
29+ ],
30+ ];
31+ }
32+
33+ if (
34+ $ message ->icon ||
35+ $ message ->color ||
36+ $ message ->sound ||
37+ $ message ->click_action ||
38+ $ message ->badge
39+ ) {
40+ $ data ['android ' ] = [
41+ 'notification ' => []
42+ ];
43+
44+ if (! empty ($ message ->icon )) {
45+ $ data ['android ' ]['notification ' ]['icon ' ] = $ message ->icon ;
46+ }
47+
48+ if (! empty ($ message ->color )) {
49+ $ data ['android ' ]['notification ' ]['color ' ] = $ message ->color ;
50+ }
51+
52+ if (! empty ($ message ->sound )) {
53+ $ data ['android ' ]['notification ' ]['sound ' ] = $ message ->sound ;
54+ }
55+
56+ if (! empty ($ message ->click_action )) {
57+ $ data ['android ' ]['notification ' ]['click_action ' ] = $ message ->click_action ;
58+ }
59+
60+ if (! empty ($ message ->badge )) {
61+ $ data ['android ' ]['notification ' ]['notification_count ' ] = $ message ->badge ;
62+ }
63+ }
64+
65+ if (! empty ($ message ->extra )) {
66+ $ data ['data ' ] = $ message ->extra ;
67+ }
68+
69+ return $ data ;
70+ }
1471}
You can’t perform that action at this time.
0 commit comments