Choose sounds for push notification in my app

落花浮王杯 提交于 2019-12-11 10:49:58

问题


I am working on app and need to let the user from my settings on app to choose the tone for push notification from system sounds. How to let user open system sounds and choose one for push notification?

Like whatsapp notification settings

Like this link

link


回答1:


Step 1: Include all possible tones in your app's bundle

Step 2: Allow user to select which tone they want

Step 3: Store that on server somewhere

Step 4: When pushing that user, include their desired sound in the package

aps : {
    alert : "Some Message",
    sound : <#userPreferredSound#>
}



回答2:


You don't have to let your server know what sound the user has selected. The notification JSON payload should contain some custom value like "push_sound" for the sound field. Every time a user selects a sound save the newly selected file into 'Library/Sounds' folder and name it "push_sound". That's it



来源:https://stackoverflow.com/questions/27460177/choose-sounds-for-push-notification-in-my-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!