I have an app with a behavior that I want to copy. The app can play music in the lock screen state. The app can also turn off the screen at this state. I'm not too sure if the app is placing the Mac in sleep mode but the white indicator light on the front of the Mac book is on but is not pulsing while the display is off.
I know how to play music and place the mac in the lock screen state using apple script. What I don't know how to do is turn off the display and have the indicator light turned on. This behavior is similar to when the Mac is in sleep mode. Any ideas as to how this can be done programmatically using objective-c and/or apple script?
I cannot use anything that is not documented by Apple. I am running the latest version of OSX Lion.
If you hold down the command, shift and eject buttons at the same time, the screen goes dark instantly. I just confirmed this in 10.7.1.
As for Applescripting Display Sleep, it's not trivial. I did find a probable solution in this thread:
http://macscripter.net/viewtopic.php?pid=135732#p135732
Give it a try and see if it accomplishes what you are looking for.
Related
I've been using Wineskin for quite a while, and, as of late, I've been attempting to use Winemac.drv (or Mac Driver) from CodeWeavers more than X11. The main difference is that Winemac is fully programmed in Objective-C (including its Window system), while the X11 approach uses X11 dylibs and .nib files for windows.
Since Winemac's still in development, however, it lacks in some OS X functionality*. The feature in mind is bouncing on Dock. What's the problem with the bouncing? Well, it simply just doesn't bounce. More specifically at launch. The code somehow overrides the user's option for "Animating apps on launch", or does something that completely ignores the usual app launching animation.
I've still very little experience in Objective-C, so I might've missed some key documentation from Apple's Mac Documentation Library, but my question is:
Can apps usually override this option, or might this be the case just for Wine? If they can, how?
EDIT: I've stated incorrectly that the Mac Driver missed on functionality, when the reality is, as mentioned by Ken Thomases, that Wine processes start at background, so no icon is shown on the Dock at launch, and that means no animation.
I'm the developer of the Mac driver for Wine.
The issue is that all Wine processes start life as background processes with no presence on the Dock. Many Wine processes remain that way because they never present any windows.
When a Wine process does present a window for the first time, it transforms itself from a background process to a foreground process. At this time, it gains a presence on the Dock and in the Command-Tab application switcher and gets a main menu bar. It just so happens that the Dock does not bounce the icon of an app which transforms from a background process to a foreground process. Basically, the Dock is getting involved well after the process was launched and bouncing is for a process which is launching.
An application can make its Dock icon bounce by calling -[NSApplication requestUserAttention:]. However, this does nothing if the application is already active. Also, the bounce animation has a different quality. It's sharper and more urgent, rather than a relaxed bounce.
Basically, there's no way to achieve what you want for the general case. It may be possible to construct a script-based app bundle that configures the environment and then execs Wine. Since the app is bundled and describes itself in its Info.plist as a normal foreground app, it will get a Dock icon immediately and that icon should bounce. I'm not entirely sure how things will behave from there, in terms of the execed Wine taking over the Dock icon. Even if it works for the initial process, any Wine processes which are launched by the initial process will revert to behaving in the manner you're familiar with. (For example, many games have a patcher/launcher which launches a secondary process for the game itself. You might get the patcher/launcher icon to bounce, but that wouldn't help for the game process's icon.)
I'm interested in a border line iPhone app able to detect the user location continuosly.
The app will be delivered in enterprise mode (so no Apple approval).
Basically it should run forever (resetting the backgroundTimeRemaining through the location service start end stop).
the issue that I was not able to fix is to relaunch the app after a reboot, event if I declare the voip capability, it seems that the system give me only 3 minutes, no more time despite all the workarounds.
so actually I'd like to know if someone was able to implement this sort of behaviour on iOS7.
thanks in advances, please find below some references.
iPhone - Backgrounding to poll for events
to run app continuously in the background
Background Location Services not working in iOS 7
Start Location Manager in iOS 7 from background task
ok, I got it.
the music hack is the solution.
During the further 180s of background time a small mute playback of few seconds (of local mp3) restart the backgroundTimeRemaining counter.
bye
I've integrated opentok ios sdk in my iOS 7 app, it is working fine, except this problem:
During video chat if I don't access iPhone for 5-10 seconds..then my app moves into background, causing viewer at other end to hear only audio. Video is disabled after app goes to background state.
I've observed same thing with their official example
https://github.com/opentok/opentok-ios-sdk/tree/master/samples/OpenTokFullTutorial
How can I avoid my app going to background while video chat is ongoing. Skype is working fine in this case, I want to achieve same thing.
What you want to do is prevent the iPhone from going to sleep. To do this, you cant try this:
[UIApplication sharedApplication].idleTimerDisabled = YES;
Here is iOS documentation on idleTimerDisabled
If you don't want the app going into background at all (like when the user taps on home button), you can opt to kill the app when it's not running instead of having it run in the background. To do that, check out iOS guide on opting out of background execution
If you do not want your app to run in the background at all, you can
explicitly opt out of background by adding the
UIApplicationExitsOnSuspend key (with the value YES) to your app’s
Info.plist file. When an app opts out, it cycles between the
not-running, inactive, and active states and never enters the
background or suspended states. When the user presses the Home button
to quit the app, the applicationWillTerminate: method of the app
delegate is called and the app has approximately 5 seconds to clean up
and exit before it is terminated and moved back to the not-running
state.
Hope that helped!
Does anyone know if there is a way to force an app you're developing to run in a 3.5" screen size mode if you're on an iPhone 5, just for dev/debug purposes? Something such as what might look like a toggle in the Development section of Settings or something. In other words, run the app such that it LOOKS like it's running on a non-5 iPhone (black bars on top/bottom), that way I can test certain UI functions.
For clarification, I'm NOT saying "I don't want to support iPhone 5" - I most certainly do. Also, I'm aware that I can do the 'old' retina display in the simulator, but I do not want to use the iOS Simulator as the app includes libraries that do not support i386 architecture, uses push notifications, and heavily relies on GPS to function correctly. I'm just looking for a way to test both aspect ratios on the same device to save money/time.
Thank you!
It appears that by removing the app from device, deleting the Default-568h#2x.png launch image, cleaning the project, and re-running app, I can get the functionality I'm looking for, although not as nicely as a toggle switch.
Letter box in iPhone5
I'm working on an alarm clock application for iOS 4.x. The other alarm clock applications that I've seen are able to present the user with something other than a local notification (i.e., a custom view) and are able to play a sound file. I've been looking into how that's done and have only found this solution:
Play sound with screen turned off / don't let iPhone go to sleep
Is there another approach or is this the best practice?
When your app is not visible, you can't display anything. The silent sound workaround is a cool trick but when a user presses your home button, your app is not visible (and might get destroyed under certain conditions) -> therefore you can't display anything.
So if you tell your user to use your alarm clock by firing it up and then press the sleep button it will work - you can display anything on your screen after the user unlocks the iphone again.
Needless to say that playing sound (even silent sound files) drains the battery so your user might be disappointed if he's not woken up because his iphone has run out of battery.
And yes, there is best practice: Local Notifications! Beginning with iOS 5 it will display your apps icon next to the notification...