I am making a chat app. The user can select the notification sound for a particular chat/group. When the app is in the killed state, if a new message arrives I want to play the sound that the user had selected for that chat otherwise play default sound. How can I do this?
App bundle must have your all sounds file
User selected sound name and feedback to you app server
Your APN server get the selected sound and push notification with the sound name
Related
I am new in iOS development, and I am working on an iOS app in which some options are available for user to get pushNotification, such as users can select "Do not Disturb", "AnyTime" "time b/w"...something like this. So If user choose "Do not Disturb" then I do not have to play sound and alert. So please give me solution of that.Is this possible or not in iOS App development. Please tell me.
Thanks in advance...
If you don't require sound for the push notification, Don't give sound object in push payload.
If the user has chosen "Do not Disturb", indicate the server sending push notification to remove sound from the payload.
{
"aps":{"alert":"Hello","category":"your_category_key"}
}
Other wise include sound.
{
"aps":{"alert":"Hello","sound":"default","category":"your_category_key"}
}
I am building my first app but wanted to know if there is a way to send updates or activity notifications to a user without a push notification.
These updates could include:
icon badge
Sound
Alert that appears on the lockscreen (I believe this is the push notification)
What can be done without requiring the user to give permission? I have tasks for the user at x time and want to remind them at that time.
I have to set custom sound when I receive APN in my iOS app.
For custom sound I mean a sound that every user can change within his app and not different from the default sound.
I already know that I can set the attribute "sound" on the payload of my notifications, but what I would like to understand if there is a way to play a different sound based on the user's settings (user A can set sound1.aiff, user B can set sound2.aiff).
The only way that I can see is that the notification is already sent with the name of the file to play that the user has set on preferences: this means that I have to store settings on server-side. Now I do not this.
Do you confirm me that's the only way?
Not an ideal solution, but this might work for you...
Send a silent notification instead. When your app receives the silent notification, check the user’s settings and post a local notification with the desired sound.
i have an application that receive push notifications, i would like to implement a user settings profile with a "silent notification for x hours".
How can i prevent the sound of the notification? there's a something on a server or in a client?
Because now i can prevent the sound if the app is in foreground or background, but if the app is suspended how can i intercept and lock the sound and the notification?
Somethings like whatsapp or telegram application!
Thanks!
Upload the user settings to the server and ensure that the server doesn't send any push notification during the silent hours. During that time if the user opens the app they should be able to download the content but they shouldn't be notified about any new content when the app isn't already open.
I'm wondering if it's possible to allow the user to change the push notification sound for my app in Settings.app->Notifications to any of the default sounds (similar to how the alert tone for Messages can be changed there). If so, what do I need to change in code to allow this? Do I need to change the Settings.bundle?
You can send the name of the sound file chosen by the user to your server (along will the device token) and store it in your DB. When you send a push notification to that user's device, you'll fetch the sound file name from the DB and put it in the sound property of the notification payload.
If the user doesn't choose a specific sound, you can send a default sound file name in the notification payload.