【发布时间】:2016-02-25 13:26:44
【问题描述】:
我有一个 react-native 应用程序,它可以使用 react-native-gcm-android 包接收推送通知。我想在收到推送时播放声音(默认或自定义)。
我尝试了我的 gcm 有效负载的一些变体,但没有一个版本可以播放:
dataPayload = {
'title': 'Stackoverflow',
'badge': 'Increment',
'alert': alert,
'notification': {
'subject': 'Stackoverflow',
'message': 'Some message',
'sound': 'default'
}
}
dataPayload = {
'title': 'Stackoverflow',
'badge': 'Increment',
'alert': 'Some text',
'notification': {
'subject': 'Stackoverflow',
'message': 'Some message',
'sound': 'android.resource://com.mypackagename.myapp/sound.mp3'
}
}
dataPayload = {
'title': 'Stackoverflow',
'badge': 'Increment',
'alert': 'Some text',
'notification': {
'subject': 'Stackoverflow',
'message': 'Some message',
'sound': true
}
}
sound.mp3 文件位于android/app/src/res/下
【问题讨论】:
-
你应该把你的 mp3 文件放在 raw 文件夹中。参考developer.android.com/guide/topics/resources/…
标签: android push-notification google-cloud-messaging react-native