Is it possible to vibrate only on Push Notifications in iOS? - ios

I know how to use vibrate in in the foreground. I want to know how to use it in the background...
I searched a lot in stackoverflow but I didn't find the right answer, only an answer from 2011, where you use a silent soundfile (vibrate in push notification).
If the sound of the iPhone is turned on, can you make the iPhone vibrate only on a push notification? Is the silent soundfile the only way to do this?

Including the silent sound file to vibrate still works with iOS11.
Make sure you request the sound attribute for your notifications.

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 UILocalNotification sound while do not disturb mode is on?

I can't seem to find a way to play the local notif sound when do not disturb is on, it's for an alarm clock app so it's kind of essential that the sound play even when do not disturb is on. Is there anyway around this?
As another option I've considered having a blank audio play in the background until I need the alarm called, but I've heard that Apple would reject this method.
Why would you need to play when the phone is in do not disturb mode? Chances are that if the user wanted to hear the alarm they would disable the do not disturb mode. I don't think there is a way to get around your problem.

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.

can we stop vibrate and play sound when push notification comes (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.

Resources