推送通知的自定义声音

时间:2017-03-01 20:52:34

标签: ios firebase push-notification firebase-cloud-messaging

从Firebase Messaging控制台发送邮件时,我可以在我的应用中收到推送通知。

但是,我想要播放我应用程序包中的mp3而不是默认声音。

以下是我发送邮件的方式: enter image description here

但是当我检查通知时,userInfo [" aps"] ["声音"]的值是'默认'。因此它播放默认声音。

userInfo [" sound"]的值设置为我的文件名,这不是帮助,因为这超出了userInfo [" aps"]。

如何获取userInfo [" aps"] [" sound"]的值作为我的自定义文件名?而不是默认。

1 个答案:

答案 0 :(得分:0)

事实证明,您无法通过Firebase控制台为userInfo [" aps"] ["声音"]设置自定义值。因此,对于测试,您必须以不同方式发送推送。

相反,您可以使用Easy APNs Provider mac应用。您为此提供了之前生成的APS推送证书,以及您设备的令牌(如图所示):

enter image description here

您可以在批准应用推送服务后获取令牌:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    let deviceTokenString = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
    print(deviceTokenString)
}

现在,我的自定义声音播放是因为推送的有效负载结构合理。如果Firebase能够从他们的控制台解决这个问题,那就太好了。与此同时,我将使用这种方法。

相关问题