For an app I am working on I am using CGEventPost to post some key events and I noticed that it stopped working with sandboxing enabled, even I turned on the "Enable Access for Assistive Devices" system preference.
Is there an entitlement to allow the use of CGEventPost? Or, is there another way to post key events with apps submitted to the Mac App Store?
Can Mac App Store Sandboxed apps use CGEventPost?
No.
Is there an entitlement for CGEventPost? Or is there any way to post key events with apps submitted to the Mac App Store?
No.
If you look at the developer forums, Apple has made it very clear that they will never enable an entitlement for this, because it allows a blatantly obvious way for any app to escape the sandbox.
If you have some more specific need that you can justify (not "post some key events" but "get iPhoto do to XXX, which as far as I know can only be done by posting event YYY at it"), file a bug report, and post a thread on the dev forums.
This will do two things:
Someone at Apple may suggest a workaround--possibly a private one that nobody else can tell you and/or one that isn't normally allowed on the App Store but will be accepted if you've been told to use it.
It increases the chances that Apple will invent some better way to do what you want in the future.
Old question, but accepted answer is wrong. There are apps in Mac App Store that are using CGEventPost to simulate events. For example apps "Remote Mouse" and "Mobile Mouse Server" do that. They can send input to any other app and based on symbols in those apps they are clearly using CGEventPost-function. I would like to know how are they doing it.
Related
I am working on a mac based application and need guidance on one of the features, what I am trying to do here is
When my app launches I don't want the user to interact with any other application unless the user hits the close button of the app. No keyboard shortcuts should be enabled for mac like cmd+spacebar etc.
My question is if this is doable? Is there official documentation from apple which says it won't allow doing this due to some technical reason?
macOS has supported "kiosk mode" since 10.6; it allows your application to:
Hide / deactivate the dock, menu bar and Apple menu
Disable switching and hiding of your application
Prevent restarting or shutting down the computer
Broadly,NSApplication exposes a bitmask property, NSApplicationPresentationOptions, that lets you select the combination of settings you want to use.
The best resource to read further is the archived documentation that #KenThomases located here and here.
I'm exploring the end user experience for a beacon prototype but I'm struggling to find any end-user scenarios that involve the app becoming active / opening up on the screen when within range.
I can get the app to send a notification and this is the most likely experience on both Android and iOS but does anyone know if it is possible to get the app to open up?
It's unlikely that I'd want real customers to have their experience interfered with in this way, I think it's ok if the app is already running and is open but not if it's running but not open.
Thanks
On Android this is possible. The reference app for the Android Beacon Library demonstrates how to do exactly this.
On iOS, it is not possible due to OS security restrictions. See here for details. The best you can do is send a local notification to the user when the beacon is detected, then if the user gestures to it, bring up the app.
I've tried searching and surprisingly I couldn't find anything on this. I have seen a few web apps that have desktop applications. For instance in gmail you can go into the settings and enable desktop notifications and get an alert even if you don't have the browser open at all. Also, there is an app called "slack" that I have been playing around with and I somehow got desktop notifications enabled. Also, google hangouts gives me notifications every once in a while. I don't know if this is a google chrome thing, or if it is a mac specific thing. Does anyone have any idea how these apps are posting these notifications?
Is it a browser specific thing? A platform specific thing? Did I download some type of desktop app that I have forgotten about that is enabling these apps to do this? Has anyone else created a desktop alert for their web app and how did you do it?
A similar question asked -
Chrome Desktop Notification.
From a front-end standpoint, there is EventSource for this, though you could also use websockets or polling (checking every few minutes/seconds).
Event Source and Server-Sent Events.
I have a desktop application running on OS X and Windows. I'd like users to be able to buy iTunes content from within the app, and I'd like to earn via the affiliate program.
Is this allowed, and if so, how do I do it? The documentation states:
The use of the affiliate program inside apps is perfectly acceptable
and in fact encouraged behavior for app developers.
but it's not clear if this only applies to iOS apps, or desktop apps, too. Furthermore, I don't know how to pull it of in practice: It seems I am supposed to open a certain URL*. I believe on iOS, this is intercepted, and the user is taken to the App Store. On OS X (or Windows), it seems that this would flash a browser window before opening iTunes, which I'd like to avoid. I'd like to directly open iTunes with the purchase option. Or do I have to embed a browser frame in my app and use some kind of web interface?
*) There is some redirecting, and I can improve the user experience with 'short links', or by handling the redirection manually in the background, but in the end there is always an openURL call.
www.apple.com/itunes/affiliates/
the program applies to most content types, links can be on a website or within an app. essentially anywhere a iTunes store is: Mac: iTunes and Mac App Store. and on iOS: app store, itunes store and iBookstore. and Win: Itunes Store.
I was wondering how we can access Safari bookmarks from another Cocoa application on Mac OS X, in a way that is safe and secure for the future.
As you may know, two mechanisms were common to retreive Safari bookmarks:
either read Safari's Bookmarks.plist file
or use the SyncServices API.
However, the first is forbidden by sandboxing (mandatory for a distribution through the App Store), and the second has been deprecated since Mac OS X 10.7 Lion.
I believe that Apple deprecated SyncServices in favour of iCloud synching, but I can't find any iCloud API that allow access to the bookmarks (1).
Any hint on where to look? Native Cocoa is preferred, but any non-deprecated, sandboxing-compatible solution is welcome.
Thanks.
(1) and, honestly, going through the internet (and thus requiring an internet connexion) to retrieve on a machine something on the same machine seems... awkward — but well, if it was the way to go at least that would be a possibility.
You can read out the bookmarks plist file even when running in a sandbox if you expressly ask the user for consent: Present an open panel pointing to the plist directory and store the security-scoped bookmark you receive from it. I did this and my app wasn't rejected for this (but for other things).