Different tones in local notifications - ios

I am developing a chat app. And of course, local notification is of great importance in such applications. So, I decided to take a look at the other chat apps to get an idea. Surprisingly, I found that WhatsApp and telegram have so much common alert tones. So the question is: Are the tones in whatsapp and telegram are system sounds? And if so, how to use them?
I did some search but found nothing regarding the topic!

When you send a remote notification to a device you can specify a notification sound.
As per the Apple docs the sound key should contain a string with:
The name of a sound file in the app bundle. The sound in this file is played as an alert. If the sound file doesn’t exist or default is specified as the value, the default alert sound is played. The audio must be in one of the audio data formats that are compatible with system sounds; see Preparing Custom Alert Sounds for details.
In case of a local notification you can set the property soundName to UILocalNotificationDefaultSoundName or any name of a sound file in the app bundle as well.
The notification sounds are located inside the app bundle. You *could* just unzip and explore the .ipa of the apps you mentioned.

Related

Custom sound for remote notification

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.

How can I mute my local notifications while my iOS app is in foreground?

I am using this package: https://github.com/zo0r/react-native-push-notification to schedule local notifications in my react-native app.
I can schedule local notifications that will display when the app is killed or in the background. If the app is in the foreground the visual notification is suppressed but the notification chime sound plays. I don't want the sound to play - as it can only serve to confuse or annoy the user.
According to Apple docs "The system does not display any alerts, badge the app’s icon, or play any sounds when the app is already frontmost." I've been racking my brain and bingeing on docs but I can't figure out what I could have done to circumvent this iOS policy.
Any ideas where I should look in my code?
This lib has a property that can handle it for you. Just set playSound: false.
You can mix it with AppState to toggle the value according to the state value.
More info in docs below:
https://github.com/zo0r/react-native-push-notification#local-notifications
https://facebook.github.io/react-native/docs/appstate.html
Hope it helps

Push notification arguments localization

I know that it is possible to localize the message and title of a push notification, using title-loc-key, title-loc-args and loc-key, loc-args. So, that the system searches for the localized-title-formatted-string(title-loc-key) in the app bundle and substitutes the format-specifiers with title-loc-args.
My questions would be that is it possible to localize the arguments of a push notification? So that the system substitutes the format-specifiers of the formatted-string with the localized title-loc-args(arguments substituted with the localized values found in the app bundle).
For example:
Notification:
`title-loc-key`= "localization_key_shipping"
`title-loc-args`= ["localization_key_headset"]
Localization En:
"localization_key_shipping" = "Your %# is ready for shipping"
"localization_key_headset" = "headset";
Can I make this work to see "Your headset is ready for shipping" ?
Thanks for all of your advices and comments.
No, your server side code is expected to feed in localized text for arguments. See Apple docs.
Look at the Notification Service Extensions. That is how you can modify the content of a push notification before is shown to the user.
https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension
A UNNotificationServiceExtension object provides the entry point for a notification service app extension. This object lets you customize the content of a remote notification before the system delivers it to the user. A notification service app extension doesn’t present any UI of its own. Instead, it’s launched on demand when the system delivers a notification of the appropriate type to the user’s device. You use this extension to modify the notification’s content or download content related to the extension. For example, you could use the extension to decrypt an encrypted data block or to download images associated with the notification.

Can the AVSpeechUtterance audio be recorded?

I am wondering if the audio from Siri's speech synthesis can be recorded programmatically and then saved locally.
I am wanting to create some custom voice alert audio files in Siri's 'voice' to be used to for spoken Push Notification messages instead of just using a generic sound alert.
eg I would get Siri to say "Attention David, your window has been closed due to rain" in a Push Notification alert by using a previously recorded voice file, even when the home automation App isn't running.

Changing push notification sound to a file not in the app bundle?

Is is possible for a user to record a new sound to be used as the sound for the push notifications they receive from the app? In other words, is it possible to dynamically change the push notification sound using sound files uploaded externally, or do they have to be already located in the app bundle?
From the Push notifications programming guide:
For remote notifications in iOS, you can specify a custom sound that iOS plays when it presents a local or remote notification for an application. The sound files must be in the main bundle of the client application.
So I would think that it's not possible, sorry.
The notifications will often be processed by the system while the app is closed, so I don't think there is a way to configure its behaviour beyond the basic features.

Resources