Windows Store Apps difference between Contracts and Extensions? - windows-8

Can someone provide me an easy explanation of the difference between Contracts and Extensions in Windows Store Apps?
I have read this article: http://msdn.microsoft.com/en-us/library/windows/apps/hh464906.aspx, however, in some of the examples it isn't clear why one is a Contract and not an Extension and vice-versa.
Thank you.

When you "extend" a native function of Windows 8, like taking pictures or picking files - then your app is an "extension". It is more a category of apps based on their function. Contracts, in contrast, are just leveraging the charms and device capabilities. //End
To summarize:
Many apps will use contracts.
Few (very few?) apps will be extensions.

A contract is an agreement to consume and/or supply data in a specific format, often between apps as is the case with the Share contract. Contracts result in activations and are most often invoked directly from the Charms Bar (Search, Share, Settings, PlayTo) or the Start Menu (Launch).
An extension is an agreement between your app and the operating system. It is a way to extend the OS functionality with your app. AutoPlay for example allows the OS to launch your app when an item of a particular type is selected. Camera Settings will allow you to customize the camera settings provided by the OS when the user is configuring the camera.
So in general I think of contracts as app-app or app-user and extensions as app-OS, but it is obvious some are gray areas (like File Picker, I would consider that more an extension than a contract, but it is categorized as a contract).

A contract is like an interface with the common windows 8 charm bar features such as share & search.
You can make you app available to either provide to, or receive from these contracts.
An extension is where you might say, my app id used as a third part component, or as the link suggests says your app handles files of a particular extension and presents itself as a handler perhaps for that file type

Related

Can we send email through gmail or yahoo clients in iPhone sdk

I want to send email through gmail or other message clients,is it possible in iOS.
I searched a lot but didn't find anything.
I don't want to use the default composer to send mail.I wants user to choose whether they want to send emails from the default mfmailcomposeviewcontroll or can send through gmail,yahoo.
There are a few ways in which 3rd-party developers may offer this functionality -- regardless of the manner selected, it is up to the 3rd-party vendor to decide how much (if any) of these methods are implemented and documented in the public domain as accessible to other applications or users. Ultimately you will need to consult the target product's documentation or support channels to determine if such mechanisms exist. While this is neither an exhaustive list, nor it is a list of formally supported mechanisms for achieving your goal, it should give you some insight into what to go research or ask additional questions about:
Option 1: Open URL Schemes
iOS Developers can register their applications to respond to a URL scheme like "tel://" or "sms://" or "http://". If vendors register a URL scheme it will be visible in the app's info.plist. While it won't speak to the format of any parameters you need to pass, the vendor's documentation or support personnel may be able to shine a light on those capabilities. For the HTTP scheme, iOS' MobileSafari.app is registered to respond -- the well-formed NSURL that gets passed to Safari is used as the URL to which Safari navigates when launched.
Option 2: 3rd-party SDK
Other vendors may elect to make an SDK available that you can implement in your app. Google Drive, Dropbox, and Facebook are all great examples. To incorporate these cloud filesystems or social capabilities in your own apps, you can register as a developer and follow install guides to both adopt their SDK and leverage the functionality the SDK provides.
As for your specific question, it appears as though Google's official Gmail app does have an undocumented URL Scheme that the community has discovered, reverse-engineered, and written up. While I VERY STRONGLY DISCOURAGE use of undocumented app capabilities there is nothing preventing you from using this functionality. Keep in mind that because this is undocumented, there is a distinct possibility that the feature could be removed, changed, or otherwise made unavailable in future builds that can leave your own app in a bit of a bind. Furthermore, for those of your users that do not have the Gmail app installed would not be able to leverage this URL Scheme and could lead to a poor user experience. All that said, with the caveats above, Tom Scotland has written up a series of blog posts on the Gmail app's URL scheme and updates to the scheme as a function of the rest of the Google constellation of iOS apps - http://tom.scogland.com/blog/2013/01/29/gmail-url-scheme/
Yahoo Mail is a separate issue -- As far as I can tell, this app offers neither of these access options, however I'll leave the digging as an exercise for the OP.
Again, I encourage you to use MFMailComposerViewController instead of unofficial or unapproved app capabilities so as to limit your own app's exposure to changes beyond your control.

Tracking file changes done by an external apps

Is it possible to get a handle on a file which is opened by any external app via my application?
Using Cloud-Storage Apps as an example, I would like to track changes to a file opened via the Storage-Provider App, so the manipulated file can be uploaded again afterwards.
There are two possible answers here, depending on what kind of app you're implementing.
For general tracking purposes, you can try using the ContentsChanged event of the StoreFolderQueryResult/StorageFileQueryResult classes within Windows.Storage.Search. That is, you create a file or folder query for what you want to watch, and then register an event handler. Generally speaking, this works well for stuff on the local file system; it's not guaranteed if you're trying to run a query on files/folders whose backing store is elsewhere.
The subject is too detailed to be described here, but you can refer the "File and Folder Queries" in Chapter 11 of my free ebook Programming Windows Store Apps with HTML, CSS, and JavaScript, Second Edition, page 607. Even though I focus on JS as a language, the discussions of WinRT APIs like this are useful when working in any language...plus the ebook is free so there's nothing to lose.
The other mechanism would be useful if you're implementing an app that provides the interface to a cloud storage backend, like the OneDrive app that's part of Windows. In this case you'd want to use the CachedFileUpdater contract. See Appendix D, page 1288, of my aforementioned book.

Common Session for Windows Store Application

Our Team is trying to build multiple Windows 8 Store Apps for an enterprise.
How do we maintain a common session for all apps(where we store data which need to be shared)?
How do we enable direct interaction between the apps developed i.e. sharing objects or string(JSON) among the apps?
There is not built in way to do this. Realistically you probably have three options to share data between applications.
The first is to use the cloud / web services. This makes the most sense as you'd have full control about what is shared, authentication etc. Using libraries such as SignalR could let you add real time functionality between the applications as well as multiple users.
The Share contract, by using custom data formats you could enable the apps to share specialised data between each of them. This can make sense if the user has a set of data they want to send to another application to enable a quick piece of workflow as the Share target is only partially launched. This also is limited in that it's enabled by user action.
Custom protocol handlers, by giving each app it's only protocol my-custom-app:///some-action?param1=value etc then you can pass data between apps, note this launches the app in question when you launch that uri. This would be best for more longer running scenarios.
I'd suggest a combination of all three depending on the user action. Cloud services to store the data for the user and then a mixture of Share and Protocol to enable to the user to smartly move the apps seamlessly.
Here exactly the same question as yours. In short: there is no such ability. Sometimes I think that it will be easier to share data via Internet that in device.

Using Windows 8 Store App Share Contract

As I understand the share contract for Windows 8, when I provide some information in a share contract, I should see any installed apps that are capable of consuming that information. I have the following code:
request.Data.SetText(myString);
However, when I select Share, I'm presented with only the mail app. What I'm after is a way to launch a work processor (e.g. MS Word) from my app. Is there something else that I need to do to mark the data I'm sharing as "compatible" with Word? Or is this just not possible because Word is a desktop app?
You cannot use the share contract to move data from a Windows Store app to a desktop app. If you look at Sharing and Exchanging Data - http://msdn.microsoft.com/en-us/library/windows/apps/hh464923.aspx - it states, "One advantage the clipboard has over sharing is that it's the only way to move data from Windows Store apps to the desktop, and vice versa."
It's true that you can't share data to desktop apps, also the target app needs to register itself as a share target for sharing to work.
You mentioned though that you wanted to launch Word. This is possible using the Launcher class if you have a Word file that you need to open:
var file = await ApplicationData.Current.LocalFolder.GetFileAsync("Test.doc");
await Launcher.LaunchFileAsync(file);

Google Analytics for Mac OSx application

Is it possible to use Google Analytics API's to track Mac OSX applications?
If not could any one suggest me an alternative for Google Analytics.
Google Analytics is designed to work with web applications not for desktop apps. Although it might be possible to collect info about your application and send it to your Google Analytic account but the amount of work required to retrofit might be better spent, building your own Analytic solution.
A good starting point would be to create a simple web service, which collects information regarding clicks. Then rewrite your application to call that web service on every click within your application.
You would ideally want to store this information locally and submit it to the web service in batches. You would also want to design the application, so that if you ever shut down the web service, the application would still be able to operate.
UPDATE: As pointed out in the comments by Václav Slavík, they have added apps analytics for iOS/Android.
I made a simple set of classes for doing this:
https://github.com/stephenlind/SimpleCocoaGoogleAnalytics
Google Analytics is not only for web applications, but also for mobile. It's available on the platform like android, iOS, etc. If you want to track your MAC OS X application, you can choose DeskAppTrack or DeskMetrics. DeskAppTrack is only available on MAC. It provide a professional data statistical analysis and it's free. While DeskMetrics is available on MAC and Windows. Either one is ok.
This really depends on how detailed you want to get. If you are are truly looking for analytics with detail and control flow data, you are better suited to created your own web service, as mentioned.
However, if you simply want to know a small number of operations, that occur at a small volume, i.e. when the app is launched (a quick and dirty solution): then in theory you could create a landing page on your site that contains a minimal head section, and a blank body, and then load the URL with an NSURL when you want to trigger the action.
Of course, you would have to include the google analytics tracking codes in the header, and you may need to load an off-screen webview to get the javascript to run. Like I said, quick and dirty.
In either case, you want to make sure the application will continue to perform properly, even if the web service / page is not present.