开发者

vibrate in push notification

How can I set that device should vibrate if a pus开发者_Python百科h notification come to my application?


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 :-)


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.


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


You just need call this line:

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜