ios - Make iPhone vibrate on Local Notification -
i developing app voip functionality. when new call comes in sending out notification custom sound. if phone on vibrate, vibrates once default. make phone vibrate during entire, custom sound (30seconds). there "build-in" way? or have actively trigger vibration appdelegate when receive voip push? can face appstore certification problems if there? (facebook messenger , wechat provide behaviour example, there has way :) )
thanks in advance rafael
there 2 seemingly similar functions take parameter ksystemsoundid_vibrate:
1) audioservicesplayalertsound(ksystemsoundid_vibrate); 2) audioservicesplaysystemsound(ksystemsoundid_vibrate); both of functions vibrate iphone. but, when use first function on devices don’t support vibration, plays beep sound. second function, on other hand, nothing on unsupported devices. if going vibrate device continuously, alert, common sense says, use function 2. first, add audiotoolbox framework audiotoolbox.framework target in build phases.
then, import header file:
#import <audiotoolbox/audioservices.h> also, if want vibrate once every 5 second (or whatever), can this.
viewcontroller.h
nstimer *timer //declare globally (in header file) viewcontroller.m
timer = [nstimer scheduledtimerwithtimeinterval:yourinterval target:self selector:@selector(yourselector) userinfo:nil repeats:yes]; -(void)yourselector{ audioservicesplaysystemsound(ksystemsoundid_vibrate); } you can stop timer (when user answer phone) calling [timer invalidate]
Comments
Post a Comment