[Code Note] calls the system vibration and sound, and calls the code note to vibrate
Code:
RootViewController. m
# Import "RootViewController. h "# import <AudioToolbox/AudioToolbox. h> @ interface RootViewController () @ end @ implementation RootViewController-(id) initWithNibName :( NSString *) bundle :( NSBundle *) handle {self = [super initWithNibName: nibNameOrNil bundle: nibBundleOrNil]; if (self) {// Custom initialization} return self;}-(void) viewDidLoad {[super viewDidLoad]; // Do any additional Setup after loading the view. self. title = @ "RootViewController"; // the vibration does not vibrate. Is there any sound that is the same as that set on your phone. // Call system vibration [self getChatMessageGoToShake]; // call system sound [self getChatMessageGoToSound];} # pragma-mark-call system vibration-(void) getChatMessageGoToShake {// call AudioServicesPlaySystemSound (audio) ;}# pragma-mark-call system sound-(void) getChatMessageGoToSound {// call system sound NSString * path = [NSString stringWithFormat: @ "/System/Library/Audio/UISounds/% @. % @ ", @" sms-received3 ", @" caf "]; if (path) {SystemSoundID sd; OSStatus error = AudioServicesCreateSystemSoundID (_ bridge CFURLRef) [NSURL fileURLWithPath: path], & sd); // if (error! = KAudioServicesNoError) {NSLog (@ "---- call system sound error ----"); sd = 0;} AudioServicesPlaySystemSound (sd) ;}}-(void) didreceivemorywarning {[super didreceivemorywarning]; // Dispose of any resources that can be recreated .}