19

How can I set that device should vibrate if a push notification come to my application?

Saurabh
  • 22,743
  • 12
  • 84
  • 133

5 Answers5

22

I just figured out one way to do this: if you want to phone to only vibrate on receipt of a push notification, you need to have a silent sound file in your application bundle, for example "silence.aif" ... if you specify that sound file in the APS notification, the iOS device will "play" the silence.aif from your application bundle, but since the sound is silence, there is nothing to hear. However the notification vibration is still triggered :-)

Jesse Hammons
  • 271
  • 2
  • 3
13

I don't think it is possible to instruct the notification to vibrate. If you set a sound using soundName the notification will vibrate if the iPhone has Vibrate set to ON in Settings > Sounds, i.e. it depends on the settings of the individual iPhone.

Robert Höglund
  • 10,010
  • 13
  • 53
  • 70
2

Setting sound : "default" makes it vibrate for me. Even when phone is not on silent, it plays no sound and only vibrates.

Seb Kade
  • 1,933
  • 2
  • 11
  • 7
0

You just need call this line:

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
vibroto
  • 188
  • 1
  • 5
-4

Omitting the sound key should do the trick:

{"aps":{"alert":{"loc-key":"SOME_KEY"}, "badge":1} The docs state that "If the sound file doesn’t exist or default is specified as the value, the default alert sound is played.". What they don't say is that if you don't provide a sound key at all, no sound will be played. If no sound is played, the phone should not vibrate as well.

if the iPhone has Vibrate set to ON in Settings > Sounds,and remove "sound="silence.caf",the end will be: doesn't vibrate

Sage
  • 120
  • 6
  • The first paragraph answers the opposite of the question (how to **prevent** vibrate). Moreover, it is a copy-paste of my answer to the opposite of the question: http://stackoverflow.com/questions/23752957/how-can-i-create-ios-push-notifications-that-don-t-vibrate/23968896#23968896 – Tammo Freese Jul 16 '14 at 09:08