1

Firebase 콘솔을 사용할 때 다음과 같이 "고급 옵션"에서 "사운드"를 활성화하면 모든 것이 완벽합니다. 가장 좋은 답변 인 Mouad Abdelghafour AitAli는 수락 된 답변 Firebase Push notification is not playing sound when app is in background에 썼습니다. 끝점 https://fcm.googleapis.com/fcm/send에 대한 요청을 작성하는 cURL을 사용할 때 알림이 수신되고 유일한 문제는 알림이 소리를 재생하지 않는다는 것입니다. 내가 \"sound\":\"default\"을 사용하고 어떻게cURL을 사용할 때 Firebase 푸시 알림 소리가 재생되지 않습니다. https://fcm.googleapis.com/fcm/send

C:\curl>curl -k -X POST --header "Authorization: key=<My authorization key>" --header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "{\"to\":\"<Token of device that receives the notification>\",\"notification\":{\"body\":\"Yellow\"},\"priority\":10,\"sound\":\"default\"}" 
{"multicast_id":4910170660116070247,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1512975815064180%efad4c69efad4c69"}]} 

공지를하지만, 알림은 여전히 ​​소리가 재생되지 않는 : 이것은 내가 명령 프롬프트에서 알림을 보낸다 방법이다. 필자가 언급 한 것처럼 Firebase 콘솔에서 작동하기 때문에 명령 행에서 cURL을 사용하여 작동하지 않는 이유를 이해하려고합니다. 고맙습니다.

+0

https://stackoverflow.com/a/46586285/7666442 –

+0

@Nilu 이미'이 내 AndroidManifest.xml에서 '. Firebase 콘솔에서 푸시 알림을 보낼 때 이미 Firebase 콘솔에서 사운드 옵션을 활성화했지만 질문에서 언급했듯이 작동하지만 cURL을 사용하여 명령 프롬프트에서 알림을 보내면 사운드가 재생되지 않습니다. 내 페이로드에서 사운드 키를 사용하고 있습니다. 귀하가 공유 한 링크 (https://stackoverflow.com/questions/46586215/android-notification-not-getting-sound-and-vibration/46586285#46586285)에서 제안 된 내용을 이미 완료했습니다. –

답변

1

잘못된 위치에 \"sound\":\"default\"이라는 매개 변수가 있습니다. 나는이 다음 코드를 사용하여 고정, 나는 기본 사운드는이 통지를 연주와 함께 통지를받은 :

C:\curl>curl -k -X POST --header "Authorization: key=<My authorization key>" --header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "{\"to\":\"<My device token>\",\"notification\":{\"body\":\"Yellow\",\"sound\":\"default\"},\"priority\":10}" 
{"multicast_id":6830402283642572741,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1512977917758257%efad4c69efad4c69"}]}