2

Is it possible to shake the iphone when the home screen is displayed and make my app open?

for eg : triggering

(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event to open my app. Is it possible in ios5 using public sdk?

I am more interested in the technical aspects than the usability so please, if you think that's a horrible idea or you want to ask me what would I do such a thing, then I would say thanks but I understand that!

I dont want to hack into OS, use a jailbroken phone...but more curious to know can an app in itself have the complete logic to achieve the same?

EDIT

I accepted the answer "not possible" but then got another answer/comment from @skippy saying it might be possibel so I am going back to figuring it out mode. Will update accepted answer accordingly!

Vikas Singh
  • 1,781
  • 7
  • 27
  • 54
  • 3
    God I hope not. That would be quite annoying. But seriously, I would imagine no. That would require the OS listening for the event then opening your app. This would require the user to set the app they want to open when shaken, and as far as I know, that setting does not exist. – Corbin May 22 '12 at 06:34

3 Answers3

7

This is not possible. Even if it was its not a good idea, think about what would happen if two apps could do this...

Sven
  • 22,475
  • 4
  • 52
  • 71
6

Unfortunately no. You can handle shake-style events only when your application is already running.

Maksim
  • 2,054
  • 3
  • 17
  • 33
1

I think it's possible, but complicated.
The first app run in background (read about required background modes).
This app must call the second app in case of shake.

It's strange behaviour, read about:
Launch an app from within another

Community
  • 1
  • 1
theWalker
  • 2,022
  • 2
  • 18
  • 27
  • Possibility of the shake gesture in bkg is the main question. Many peoples say "not possible". Check this app: http://www.itracknmap.com/app.php – theWalker May 22 '12 at 07:07
  • The pp description says you can shake the phone and do stuff(send gps location) but its $3.99 and I dont want to spend money just to make sure they do what they are saying...Have u tried it? – Vikas Singh May 22 '12 at 07:29
  • I have idea - key question is: how to read accelerator in loop, not by the automatic updates... – theWalker May 22 '12 at 07:59
  • 1
    Even if you can detect the shake, I don't think you can open the second app if the first app is running in background. – murat May 22 '12 at 08:29
  • @sanjana: Three considerations: first: it is possible to launch another app but only from the app that is running in foreground; second: you allready mentioned it: reading accelerometer in loop (in background) would be a big no-no even if possible. THIRD: even if all this was possible - all the shake functionality of other apps would be overriden. Let's say i type a memo and want to undo the typing with shake gesture - and your app shows up instead. Please don't do it :) – Rok Jarc May 22 '12 at 08:30