can we stop vibrate and play sound when push notification comes (ios)? - ios

I know the ways for,
1.how to stop playing sound and stop vibrating(simultaneously) while push notification comes from server to iPhone device
2.Only playing vibrate with no sound.
but I did not find any way to "play only sound and stop vibrating when new push notification comes" on device.

Long answer: when the phone is set on vibrate, it is not possible to set it so that it will play a sound. The other way around is possible - vibrating without sound, when a push notification is received.

Related

How to play user device notification sound in iOS

I am working on app and there I need to play sound when there is FCM notification.
I know I can play custom sound and I can play system sound(iOS). see below for code to play system sound
AudioServicesPlaySystemSound(1003);
I have seen this link and this link but nothing is what I want.
What I want:
I want that When the fcm notification come, I want to play the message/Notification sound that has been selected by user as default notification/message sounds. Also if the device is on silent it should not ring in this condition
NOTE: I know we can send sound name in FCM payload and add similar sound file in bundle But I really want to play sound that has been selected by user.
Please help me. I am right now helpless to play that sound.

How to play longer music as Notification alert?

I want to set a music which is longer than 30sec as notification soound. But after searching about this I came to know that it is not possible to add these type of music as notification sound. notification sound must be in 30sec longer otherwise it will not play music. Now how can I add more than 30sec longer music as notification sound?
I had a similar issue for my alarm app as well. What I did was a workaround when your app is in background. You play a music file in your code in background and increase the volume of the device to maximum. You can play as much longer music file as you want. Stop playing the music when someone clicks on the notification.
The only problem with this is that your app should not be killed or terminated.

Set vibration sound to vibrate on iOS

I'm creating an app where you can "send" vibrations to your contacts.
In IOS how do you set the sound for notifications from my app to vibrate, I want it to vibrate even when silent is off. Also I want the users to send custom vibration patterns, would that work or can you only play a sound once. It should work even when the app is not in background.
Try This Code :
1) AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
2) AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

How can I prevent my iOS VoIP app from playing audio when the user switches their phone to silent?

I'm building a VoIP app on iOS and I'm using the AVAudioSession category of AVAudioSessionCategoryPlayAndRecord, which is recommended for VoIP apps that need to constantly play and record audio.
However, when the user switches their iPhone ringer to silent mode, the VoIP application will still play sound for an incoming call. This is not desired behavior.
Is there a way to prevent the incoming calls from playing audio when the user has their phone on silent, but still allow them to answer the call and have audio resume?
If you take a look here at the docs for AVAudioSession Categories, you can see that AVAudioSessionCategoryPlayAndRecord unfortunately does not obey the silencing of a phone, as seen below:
Your audio continues with the Silent switch set to silent and with the screen locked. (The switch is called the Ring/Silent switch on iPhone.)
If you want the audio to stop when you turn the phone to silent, you should use AVAudioSessionCategoryAmbient.
I think I found a solution that works for a VoIP application. If the phone is set to silent, I wanted the phone to show an alert and vibrate instead of playing the audible ring.
I can solve this by using local notifications and moving the sound out of the application and adding it to the notification itself. By specifying a sound file as part of the notification, iOS will handle whether it should play the audio or vibrate the phone. This is determined by the position of the Ring/Silent switch on the side of the phone.
Here's an Apple article on adding a sound to a local notification.

How to detect if UILocalnotification sound is playing or not

In my application I am using 'UILocalNotification` with a 30 sec audio file. I fire the notification when device is in lock mode. I tried to drag the notification on lock screen, then application will open at that Notification sound is playing, I need to recognize notification sound is playing or not when app is in foreground.
No good way, but you can use NSTimer. Start timer after show notification and make work when timer notify you. It will work, but use it only if any other resolution don't work.

Resources