Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 18    Views: 652

theGreek
Aspiring developer
Profile
Posts: 648
Reg: May 25, 2011
Schaumburg, IL
7,830
03/12/12 03:38 PM (13 years ago)

Add a vibrate function to an IOS Device

Vibrating your device makes a huge impact on your app wether the user did something wrong and your warning them or there playing a game and the device vibrates on the users input to the game which makes your apps more exciting and more enjoyable. Untested by me. But another fellow coder at another site said it works.... The code ViewController.h -(IBAction)Vibrate; ViewController.m #import "ViewController.h" #import "AudioToolbox/AudioToolbox.h" @implementation ViewController -(IBAction)Vibrate { AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); }
 
AppGuy30
Code is Art
Profile
Posts: 737
Reg: Oct 29, 2011
location unknow...
14,070
like
03/12/12 03:53 PM (13 years ago)
Hmmm where would we add this in to xcode?
 
Marko
buzztouch Evangelist
Profile
Posts: 558
Reg: May 04, 2011
UK, Alcester
8,880
like
03/12/12 04:04 PM (13 years ago)
Brilliant tip, could this be integrated into a quiz if they got the wrong answer?
 
theGreek
Aspiring developer
Profile
Posts: 648
Reg: May 25, 2011
Schaumburg, IL
7,830
like
03/12/12 04:14 PM (13 years ago)
I bet it can... Now we just need some smart person to come by and let us all know what the practical applications would be and the way to implement. But your quizz idea is a great one. Buzzz Buzzz wrong answer!!!!
 
Tony @ Buzztouch
buzztouch Evangelist
Profile
Posts: 528
Reg: Mar 05, 2011
Saint Louis, Mi...
24,620
like
03/12/12 04:36 PM (13 years ago)
I like it!
 
theGreek
Aspiring developer
Profile
Posts: 648
Reg: May 25, 2011
Schaumburg, IL
7,830
like
03/12/12 04:40 PM (13 years ago)
ok I found where he got it from. he sent me the link... Strange name..... http://www.geekylemon.com/WEBPROTECT-xcodevibratedevice.htm
 
tonycelestino
Aspiring developer
Profile
Posts: 213
Reg: Jun 24, 2011
Maceio
4,080
like
03/12/12 04:59 PM (13 years ago)
If you want the phone to vibrate when a user taps an incorrect answer on a quiz you could try inserting this into the showIncorrect method on BT_screen_quiz.m I'll try it some other day, I'm really tired right now. If someone want to try it let us know if it worked. =)
 
aquila198
buzztouch Evangelist
Profile
Posts: 473
Reg: Jul 22, 2011
location unknow...
10,330
like
03/12/12 05:37 PM (13 years ago)
sweet find bakakos!
 
theGreek
Aspiring developer
Profile
Posts: 648
Reg: May 25, 2011
Schaumburg, IL
7,830
like
03/12/12 06:15 PM (13 years ago)
ok I found where he got it from. he sent me the link... Strange name..... http://www.geekylemon.com/WEBPROTECT-xcodevibratedevice.htm
 
jbrzensk
buzztouch Evangelist
Profile
Posts: 56
Reg: Oct 04, 2011
Denver
8,010
like
03/13/12 11:30 AM (13 years ago)
Quicker than those. Be sure AudioToolbox is included in the Frameworks To vibrate when wrong, in the BT_screen-quiz.m add #import <AudioToolbox/AudioToolbox.h> at the top, then scroll down to find (void)answerclick below the part where it says "answer wrong" and play sound, add //Vibrate iphone AudioServicesPlaySystemSound (kSystemSoundID_Vibrate); Thats it. This can be added elsewhere following the same steps. Only works on iPhone
 
Marko
buzztouch Evangelist
Profile
Posts: 558
Reg: May 04, 2011
UK, Alcester
8,880
like
03/13/12 11:47 AM (13 years ago)
Fabulous I will put this in my next app jbrzensk This site is evolving fast Quick question - do you think user would find this a fun part of quiz if they got wrong or would you it be an annoyance, and does it run down battery
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
03/13/12 01:26 PM (13 years ago)
Works perfectly! Good work jbrzensk
 
jbrzensk
buzztouch Evangelist
Profile
Posts: 56
Reg: Oct 04, 2011
Denver
8,010
like
03/13/12 05:27 PM (13 years ago)
Sorry, clicked refresh
 
shak77
buzztouch Evangelist
Profile
Posts: 399
Reg: Jan 18, 2011
location unknow...
7,240
like
03/16/12 02:05 PM (13 years ago)
Also got the vibrate to work! Thanks jbrzensk!
 
CapItan Galactic
I hate code!
Profile
Posts: 24
Reg: Jan 04, 2012
NOLA
240
like
04/11/12 10:50 AM (13 years ago)
What about having the device vibrate when you are using the map plugin and you get near one of the pushpins on you map? I posted a question earlier asking if anyone new how to add alerts to the map function but vibrate would work just fine. Any ideas how to make this work ? Thanks, rob
 
jbrzensk
buzztouch Evangelist
Profile
Posts: 56
Reg: Oct 04, 2011
Denver
8,010
like
04/11/12 11:51 AM (13 years ago)
There is a sample code from apple called "regions" or something like that, that shows how to set up geofencing and regions and how to set up different distances and then trigger alerts. A lot more work than just adding a vibrate call.
 
aquila198
buzztouch Evangelist
Profile
Posts: 473
Reg: Jul 22, 2011
location unknow...
10,330
like
04/21/12 07:12 PM (13 years ago)
Hi Jared - thanks for putting this together. I'm trying to incorporate this into 1.5 app. On BT_screen_quiz.m (line 1063) I have this: }else{ //answer was incorrect //do we play sound effect? if([[BT_strings getJsonPropertyValue:self.screenData.jsonVars:@"quizSoundEffectFileNameIncorrect":@""] length] > 3){ [appDelegate playSoundEffect:[BT_strings getJsonPropertyValue:self.screenData.jsonVars:@"quizSoundEffectFileNameIncorrect":@""]]; } I tried to replace it and add it directly below with the snippet above, but got a 'fail' message. Can you offer any insight to why this may not have worked? Think it is a 1.5 issue? I have CoreAudio.framework - perhaps I'm missing the AudioToolbox. Where could I find that? Thanks!
 
jbrzensk
buzztouch Evangelist
Profile
Posts: 56
Reg: Oct 04, 2011
Denver
8,010
like
04/21/12 08:29 PM (13 years ago)
Right below that last parenthesis, in your example above, I have added the following: //Vibrate iPhone AudioServicesPlaySystemSound (kSystemSoundID_Vibrate); Don't replace anything, just add this little bit of code. I used 1.5 and works perfect. At the top of this file, with all the other imports, add #import "AudioToolbox/AudioToolbox.h" And to add the library, on the main window?, when you select the summary for your app, at the bottom under the icons and splash screens, is a section called "linked frameworks and libraries" Click the + and scroll to find AudioToolboxFramework
 
aquila198
buzztouch Evangelist
Profile
Posts: 473
Reg: Jul 22, 2011
location unknow...
10,330
like
04/23/12 05:30 AM (13 years ago)
Thank you Jared! That did the trick! Thank you all for sharing!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.