can i set push notification sound ?

Monday, November 25, 2024 9:25:42 PM
  • Posted: Friday, January 10, 2020 12:35 PM
  • 56
Hi

please i have an question - are there is way to set push notification sound form code like c# or js ?
or that can done only from ios code or android code ?

thanks a lot for your concern
0
  • Posted: Friday, January 10, 2020 12:50 PM
  • 953
I suppose sound for push notifications is a system sound. Sorry, I don't know how to help you.
Best regards,
Patryk

GrandNode Team
0
  • Posted: Friday, January 10, 2020 2:04 PM
  • 56
thanks a lot
but i think it can be done using firebase - like add it in config file u use ?
any idea for that
0
  • Posted: Friday, January 10, 2020 2:15 PM
  • 953
Firebase.js file is available to edit in wwwroot folder. You can try with it. But as I said before, we haven't try to achieve this kind of feature, so I'm not able to provide you correct solution.
Best regards,
Patryk

GrandNode Team
0
  • Posted: Friday, January 10, 2020 2:51 PM
  • 56
thanks a lot

i get firebase page https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support

and i know that it's not from my side it can handled by IOS or android

and i saw the code

            WebRequest tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send");
            tRequest.Method = "post";
            tRequest.ContentType = "application/json";

            var ids = new List<string>();

            if (registrationIds != null && registrationIds.Any())
            {
                ids = registrationIds;
            }
            else
            {
                var receivers = GetPushReceivers();
                if (!receivers.Any())
                {
                    return new Tuple<bool, string>(false, _localizationService.GetResource("PushNotifications.Error.NoReceivers"));
                }

                foreach (var receiver in receivers)
                {
                    if (!ids.Contains(receiver.Token))
                        ids.Add(receiver.Token);
                }
            }

            var data = new
            {
                registration_ids = ids,
                notification = new
                {
                    body = text,
                    title = title,
                    icon = pictureUrl,
                    click_action = clickUrl
                }
            };
0
  • Posted: Friday, January 10, 2020 11:38 PM
  • 56
Note: finally i did it :)

after some search i found that just add sound to c# code in file "PushNotificationsService.cs" and it works :)

            var data = new
            {
                registration_ids = ids,
                notification = new
                {
                    body = text,
                    title = title,
                    icon = pictureUrl,
                    click_action = clickUrl,
                    sound: "default" // Enable Sound
                }
            };


Thanks a lot
0
back to top
Filters