Set vibration sound to vibrate on iOS - 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);

Related

Is it possible to vibrate only on Push Notifications in 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.

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.

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.

Manage iOS alert settings from within the app

In my project I want to change application settings such as sound on/off and vibrate on/off for chat notification(Local Notification).
The Settings view look something like this:
How can I toggle between the sound and vibration from within the app.
I read in some S.O thread that the vibration is automatic with the local notification sound.
So in short I end up with this logic
Sound On, Vibrate On - Set any sound file.
Sound Off, Vibrate On - Set a silent sound file.
Sound On, Vibrate Off - ??
Sound Off, Vibrate Off - ??
How can I handle the last two situations?

Resources