I have been trying to get my device to vibrate more than once when my app is in the BACKGROUND. I do get one vibration only using the UILocalNotification presentLocalNotification api. All the questions I have read on stackoverflow related to this on stackoverflow says that it can't be vibrated more than once (and its against Apple policies if done so).
But in this video http://www.youtube.com/watch?v=AHtDMqOJeNk#t=38 the jabber app does it quiet nicely. Any idea how it is done ?
[Update] - all the answers below are for apps to vibrate more than once when in the foreground. I need it to vibrate in the background.
Apple's documentation for UILocalNotification doesn't seem to provide any way to specify the vibration of the notification. However, you can set a custom sound or a system sound using the soundName
parameter. I would imagine that some system sounds, by default, vibrate more than once.
You may also be able to subscribe to notification events in your AppDelegate and play another vibration sound there:
#import <AudioToolbox/AudioServices.h>
...
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
If your app is running, the following method is called in the AppDelegate:
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif
It may also be worth it to take a look at this GitHub project for a list of system sounds (no guarantees as to whether or not this is AppStore-safe).
A note on AppStore review with this kind of feature implemented. I checked the guidelines for iOS apps, and there is nothing in there about notification sounds, vibrations, or alert types. However, the use of private APIs is immediate grounds for rejection. So if you can do this without using private APIs then chances are your app will be approved.