How to detect a docked device in cocoa - objective-c

I've been searching all over the web and have found solutions to mounted device detection from within a Cocoa App using the NSWorkspace notification system. However this notification doesn't seem to be triggered when an Apple device is docked.
I specifically want my OSX App to detect docked iPads/iPhones, be able asses whether the iOS version of my App is installed and then synchronise files. I realise that the easiest way to do this is using iCloud, but I do not as yet have a developer membership with Apple and would like the option to be able to synchronise files without the internet.
An iTunes like system would be ideal. Any ideas.
Thanks in advance.

Apple don't provide any official APIs for doing what you ask.
Unofficially, you can try the stuff here: https://bitbucket.org/tristero/ipodaccessframework
You can definitely use it to determine whether a particular app is installed (by looking for a match for its bundle-id) and you can read/write files to/fro a particular apps document directory.
Disclaimer: this one is mine. There are definitely other libraries around that achieve similar results.

Related

How to program a sandboxed application in Yosemite

I was trying to program a simple TODO app for Yosemite with sandboxing. Apple has its tutorials for the same but they are not very elaborate. I wanted to know sandbox APIs like sandbox_init() and APIs for console logs (heard sandboxed apps use some special APIs). Could someone please point me to some open source app with sandboxing on Yosemite, so that I could see the APIs that it is using.
You don't need to use sandbox_init() etc. in order to create a sandboxed app.
Roughly, you need to understand:
Use the APIs to find well known directories and don't assume that /Users/username/Documents is the Documents folder, for example.
The app has no access to user files and must gain access via NSOpenPanel.
If the app wants to retain access it has already gained then it needs to create and store bookmark URLs, which can be reloaded during a later invocation.
If the sandboxed app spawns a child process, then that child process needs it's own set of entitlements.
Once you understand that it's normally just a case of setting Use Sandbox in the app capabilities and you're off.

How can store my APP identity on specific iOS device?

How can I keep installation track of my app on particular iOS device? Actually I want to check that my app was installed on a device or its first time installation. I tried identifierForVendor but it got change on every install.
There are a couple of ways to do this.
Easiest would be to implement Google Analytics
If you have your own reporting, you could use a 3rd part library to identify the device its on and then send that info to you... such as:
https://github.com/QuickBlox/SuperSample-ios/tree/master/Classes/Helpers/DeviceHardware

iOS App Settings/Preferences in Worklight

I am working on a Hybrid Application, targeting (for the moment) iOS. Does Worklight have a utility to handle application settings/preferences for iOS? I know how to write the native code to do this, but do not yet know how to gain access to the application settings from the JavaScript. Can anyone point me in the right direction or provide a working example?
In application-descriptor.xml, there is a worklightSettings flag you can set, however the settings page it creates is not user facing. That is, it is meant only for development time, or internal usage, and not production. It allows control of the server address that athe client connects to and change the web resources it will fetch.
So the answer is, no.
The mentioned settings page has set items in it that cannot be altered much (settings.bundle which does not allow much room for play. Maybe you could change it a bit, but doing so would void giving support to you if problems arise). I would recommend against doing so.
So this leaves you the option of creating this on your own. Maybe there is an existing Cordova plug-in that does something similar. Review these training modules of how to incorporate Cordova plug-ins to your application. Cordova bridges between JavaScript to native code, so it could be what you're looking for.

Does Titanium have method for "didReceiveRemoteNotification" of Objective-C?

I would like to receive remote push notification when the app is on the foreground. I think I can use "didReceiveRemoteNotification" in Objective-C, but how about in Titanium? I've been searching solutions but can't find anything. Does anybody help me out?
Titanium currently only supports local notifications (by default) I believe. You might want to take a look at AppCelerator as a solution.
Sorry, i was wrong last time. It's very hard to find but Titanium supports a way of interacting with PushNotifications.
Please take a look at Ti.Network.registerForPushNotifications. It provides a callback that is executed when you receive a Push Notification.
The other posted solutions below may provide a better integration for titanium so it's up to you what you want to use. But this should answer your original question.
Unfortunately Titanium only supports local notifications on iOS. If
you want to support remote notifications you can use
Urban Airship
ACS (Appcelerator Cloud Services) or
you write your own module that provides "didReceiveRemoteNotifcation" as an app event to your app
As far as i know you can only listen on local notifications by
default but you can try this method if it reacts on remote
notifications..

Can we package our existing HTML5 JS App for Windows 8

I have read some posts on S/O and also around the web. We are producing a HTML5 JS based web app that runs on the web. We are packaging it up for Google apps, and also for phonegap.
Can we package this app for windows 8? Of course, I appreciate it won't use the windows 8 features. But, will the app run none the less, as it stands. So that we can place it in the store and build out windows 8 features as we move forward.
I appreciate this is a slightly non-concise question, but I guess the real point is what is our quickest route to take our existing HTML 5, CSS, JS App and deploy it in the store and get it working on this platform.
In general, the answer is yes. The transition is not seamless, but you will be able to use a ton, if not all, of the application artifacts in Win8. A good test is if you can run it in IE10, you can run the app as a Win8 app. Again, this is a very broad brush - things you need to worry about are things like all scripts files need to be local (no CDN), changes to web and security contexts, and the fact that Win8 is a horizontal paradigm whereas most web apps are vertical. But in general, you should be able to make the move. Usual caveat - your mileage will vary.
Yes, although not recommended, you can package your existing app for Win8. You'll need to add a few bits of code though. The minimum would be to embed your app's start/init code within WinJS's first promise callback, like so:
args.setPromise(WinJS.UI.processAll().then(function () {
// your init code
}
You'll also need to create a couple of icons for the start screen and an image for your app's launch screen.
It is possible that you'll run into a few issues, like some security related restrictions, where you'll have to modify your code to use some native WinJS functions. This all depends on you app's implementation.
You can also check Microsoft's guidelines for migrating a web app to win8, here: http://msdn.microsoft.com/en-us/library/windows/apps/hh465143