Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
396 views
in Technique[技术] by (71.8m points)

objective c - Lock iOS app in single app mode programmatically

Note : I don't want to submit this app to app store.

What i want to achieve :

I want simple app with one view having two button Lock and Unlock.

Lock - This button will lock device. Only this app's screen will show nothing else will be accessible even after restart same screen will show up. Home button, gestures will get disabled similar to single app mode.

Unlock - This will unlock device and switch to normal behaviour of device.

iOS : I want this for iOS 4.3 and above.

I have checked following solutions, but these don't match my requirements

  1. Configuration profile

    Lock-down iPhone/iPod/iPad so it can only run one app

    But it is manual (reboot device, open app which you want to run in single app mode). I want to do it programmatically the way i mentioned above through my app.

  2. Guided access (iOS 6 and above)

    How to lock down user to Single App mode in iOS 6, Programmatically?

    I want it do for all os and programatically.

Is there any way to do this ? As i don't wan't to submit it to app store is there any private api, some hack for springboard to achieve this ?

Thanks in advance !!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As I know in iOS 7 there is a new feature which allow to do exactly what you want. However, it's only applicable for iOS 7 (and I believe it's only applicable to a supervised devices).

1) You will need to install restriction configuration profile with autonomousSingleAppModePermittedAppIDs key (take a look here)

This is one time step and a user will need to manually accept this configuration profile.

There is another option to use MDM to install it silently, but it could be an overkill for you.

2) You should use API:

UIAccessibilityRequestGuidedAccessSession (to lock/unlock)

It is defined here

3) And most beautility part. All of it is officially document. So, you can even submit it to AppStore.

P.S. Why do you care about 4.3 or 5? They have tiny market share by now. Most likely even iOS 6 has below 20% market share already.

Update 1

Potentially, you can try to use API which sends clicks and keys (search for GSEvent in iPhone-privateapi tag). May be using these API's you can do triple home to toggle accessibility on and off.

If this work, I think you should be able to cover iOS 6. I am not sure whether both this API and triple home click were available prior that.

It looks like this private API is unaccessible anymore in iOS 7. So, probably you can ignore this idea.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...