1

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.

  • AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); – Kex May 25 '15 at 13:14
  • Does this work even when app is not in background? – user2885424 May 25 '15 at 15:29
  • http://stackoverflow.com/a/22843899/1254172 and yes, this will work both in background and foreground – Sega-Zero May 25 '15 at 15:53
  • What about when app is NOT in background! – user2885424 May 26 '15 at 00:02
  • If you have something like a local notification/push notification then the phone will vibrate when the phone is in the background (if the phone is on silent). The code we have posted here is for when the app is running and in the foreground. So yes it vibrates when the app is not in the background. By not in the background you mean currently active and being used yes? – Kex May 26 '15 at 10:17
  • No i mean is there a way to make sure that even if the app is not currently running in foreground or background, and it triggers a notification, that the notification sound will always be a vibration even if not on silent. – user2885424 May 26 '15 at 11:22

1 Answers1

1

Try This Code :

1) AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
2) AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
Jay Bhalani
  • 4,142
  • 8
  • 37
  • 50