繁体   English   中英

接收带有声音的推送通知

[英]Receive push notification with sound

我有一个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/

如果您使用的是react-native-push-notification则可以在此处找到修复程序

声音文件应如文档所述位于/ res / raw中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM