Can I share a calendar entry via NFC without starting my app on the destination phone - windows-phone-8

Is it possible to create an NFC message that will create a calendar entry on the destination phone, without requiring my app to be installed on the destination phone?
For the moment, I've implemented it by using a custom protocol URI, but I'd like this to work even when the destination phone does not have my app installed. It would be even better if it could work on an Android destination.

You cannot do this on any phone if I am not mistaken. NFC messages at the end of the day are just bytes being transferred from one mobile device to another. If the destination device does not know how (and most of them do NOT have a build in handler for calendar event) to parse that message in order to open a native application what you are trying to do will not work.
Even if you get an NFC reader and read an NFC message design for that purpose and then recreate this in your application it will NOT be universal; meaning it will not work on any device, especially on different OS devices.
Again this is what I know so far. Don't take this for granted.

Have you tried to store a vcalendar item on a tag to see whether/how a phone reacts to this?
text/x-vcalendar or text/calendar
might be the right format to use for the NDEF record. See also this so question.
If this would not work, you might write an app that takes intents from such calendar data and sends it to the calendar app on the phone (however I don't know how that step would work).

Related

How do I structure my code to run a XAML page in a WinRT app and "return" a result?

I'm currently building a universal app for Windows 8.1 and Windows Phone 8.1.
In Windows Runtime, the file picker has a very easy to use API that looks like this:
StorageFile file = await openPicker.PickSingleFileAsync();
It treats user input as an asynchronous operation that can be awaited. In this instance, if a user cancels, null is returned, but you could imagine an exception being thrown if the user cancels.
I was wondering if there was some way to create a page so that I can create a similar API. Specifically, I am doing OAuth 2.0 authentication with a hosted service, and I want to send the user to the authentication page hosted in a WebView and return the code for requesting access tokens if the operation is successful or throw an exception if the user does not authorize my application.
For example:
var authentication = new AuthenticationAccess();
string code = await authentication.RequestAuthorizationAsync();
The call would swap out the Page in the Frame with the Page containing the WebView's, the user would be able to authenticate and then control would return back to the calling function and the page swapped back to the original page.
I'm kind of swimming in Windows 8.1 C#/XAML documentation. From what I understand, there is a global Window object that hosts a Frame object which can have its content swapped out with the different Pages in the application. Having done some Android development, I'm familiar with the Activity model, where essentially different pages can be initiated through intents and can propagate results back up to the Activity which launched it. With this model, it seems like it would be easy to wrap this process in the model I described, but I'm a little confused of how to do the same thing in Windows. Would I need to stand up significant architecture to achieve this pattern?
Is there a simple answer to this, or am I in over my head?
Have you checked out the WebAuthenticationBroker yet? Perhaps that could turn out to be an easy solution to your problem.
Otherwise - you can use TaskCompletionSource to set up the authentication task that you can await, but I'd try to avoid navigating to other pages for your authentication dialog since navigation events could mess up your states and break whomever is waiting for the authentication to complete. A dialog overlay of some sort might be a better idea.

Launch application automatically from a push notification on Windows Phone 8

I would like to launch an application using parameters provided from a push notification on Windows Phone 8.
The behaviour I wish to achieve is that as soon as the user receives the notification, the application will be launched with the parameters provided in the notification. I.e. seamlessly present the notification in a more user friendly way.
As far as I understood there are three push notification mechanisms. Toasts, Tiles and Raw.
None of them seems to be able to handle the wanted behaviour.
Toast: The message is shown even if the application hasn't been started. It does not start the application unless clicked on but seems to be closest to the target.
Tile: Message is shown if the application has been pinned. But they may be difficult to notice unless the tile is pinned fairly high on the start screen.
Raw: Works in more power states but requires the application to be running. This doesn't seem to be a match because I want the notification to be received when the application is not running. I couldn't find information about which application states where raw notifications are handled. I would prefer all.
Did I miss something in my research? If anyone has a hint of how to put an application in the foreground from a push notification (without user interaction) it would be greatly appreciated!
My first attempt was to trigger the application start using SMS but that seems to be a no go.
See my post Launch application automatically from an SMS on Windows Phone 8
You can not automatically launch an application on Windows Phone (and neither can you on iOS or Android). What you can do is provide a URI with the Push notification so the user is taken to a page with the needed information
you can not put an application in the foreground from background without user interaction.

Is there a way to persist cookies or HTML5 localStorage across WebBrowser instances on Windows Phone?

Short version: I have a WebBrowser control hosted in a Windows Phone 8 app. How can I store values from javascript so that they persist across the user closing and reopening my app?
Long version:
I'm developing a Windows Phone 8 application that has a single WebBrowser control hosted in a single MainPage.xaml page that lives for the entire life of my app. I created the app with the "Windows Phone HTML5 App" project type when creating the project in Visual Studio 2012. 99% of my application is hosted in web pages (on the internet, not stored on the phone) that I direct the WebBrowser to go to when the app starts up. In my application's web pages I'm trying to persist data across pages and across sessions. For example, once the user logs in once then I want to store that on the phone so the next time they start the app they don't have to log in again.
Cookies and HTML5 Local Storage (via window.localStorage.setItem and getItem) both work fine for sharing data across pages in the app while the app is running and even if you switch out of the app (via the Windows phone "hard button") and go back in. But if the user exits the app by pressing the hard "back" button then the next time the app is started all localStorage and cookies seem to be gone.
Is this the expected behavior? I guess I'm not sure where WebBrowser would store the data (Isolated Storage? Or maybe in the same place it's stored if going to the web site with Internet Explorer?). In any case, if there's no "fix" for this, can anyone the best way for me to provide my own storage mechanism so that I can let my javascript code persist values across instances of my app running? I'm happy to use the app's Isolated Storage if only I knew of a way to get and retrieve values from it using javascript. Thank you.
I'm not sure if this is expected behaviour or not.
To get at the Isolated Storage you will need to use JS/.NET interop.
if you want to trigger the persistent storage from JS:
Use window.external.notify in JS, generating a JSON string (for instance) to pass along to the .NET side. That could be written to IsolatedStorage without the .NET having to parse the data. You could use IsolatedStorage.AppSettings or a full file depending on the size of the data.
Alternately you could trigger the process from .NET:
Call WebBrowser.InvokeScript to call a JS function which returns the same JSON string representing your data.
The .NET side could detect and restore this data on startup and use WebBrowser.InvokeScript to pass the JSON string back into the WebBrowser via a JS function.
You'd of course have to deal with error cases (attempting to restore bad/corrupt JSON).
Also, if you trigger this from .NET in response to the App.Closing event you need to watch out that you don't take too long writing data.
The faster you run the better, but this definitely needs to be done within 10 seconds or the OS will kill your app.
See MSDN docs for WebBrowser.InvokeScript() and ScriptNotify registration to window.external.notify.

Catch NFC NDEF-Text-tags system-wide?

My Windows Phone 8 app should react to NDEF-Text-encoded NFC tags, no matter if the user is currently in another app or on the homescreen. On Android, this works by having the app "subscribe" to certain tags (e.g., NDEF-Text, in my case), and the operating system will allow the user to choose from a list of apps if more than one app can process the scanned tag. Is there anything comparable for WP8? At the moment, I am using
ProximityDevice _device = ProximityDevice.GetDefault();
long _subscriptionIdNdef = _device.SubscribeForMessage("NDEF", MessageReceivedHandler);
in my MainPage-class, which works fine, but obviously only if the user has launched my app prior to scanning a tag.
Unfortunately, for the moment NDEF-Text tags can't be handled by third party apps on Windows Phone 8.
If you want the OS to launch your app, you will have to either use the NDEF-LaunchApp record type or register a custom URI scheme.

In-app sms sending in as3

How to send sms within an iphone and android app using as3. I found this code while googling:
var callURL:String="sms:0-123-456-7890";
var targetURL:URLRequest = new URLRequest(callURL);
navigateToURL(targetURL);
Its working, but it is navigating the app to sms window controller. Can it be done without opening the sms controller window. Is there anything that opens a window within the app itself. Is there any air native extenson which perform this for android and iphone?
Yeah, using navigateToURL is going to pop you over to the phones default SMS app. To get around this you're going to need to use a native extension.
I know of one for Android:
https://github.com/mr-archano/Android-AIR-Extensions
If you have an Android phone you can check out a demo of this ANE inside of the AIRexplorer app. Select the SMS ANE version from the list (the app includes an extension as well as navigateToURL)
I don't know of one for iOS right now so you may have to do a little bit of digging
Oh Also, wanted to add a comment because I'm not really sure of your intent here.
If your goal is to send a sms without any user interaction that is not going to be possible. ANE or not
I very much doubt that either ios or android (maybe if you root your device?) would allow sending a SMS without the users explicit consent.