Thursday, June 30, 2011

WP7 WebBrowser caching and Facebook login/logout

So you want to developed your next social media integrated Windows Phone application;
And you’re making heavy use of Facebook C# SDK.

But you’ll find out that all the authentication/authorization/delegation process is done entirely in a WebBrowser component and developer is just intercepting Navigated event of this component to process the server responses and capture the Access Tokens.

It comes a bit more trickier when you try to log-out in order to log-in with another credentials.
Not so much info over the internet, so here it was my solution that works just fine:

- when we wish to log-out we pass to the browser log-out URL:

wb.Navigate(new Uri("http://m.facebook.com/logout.php?confirm=1"));

- then on the navigated event of WebBrowser component we look for logout button, extract the logout Url and we force a navigation to this real logout Url:

private void wb_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
string fbLogoutDoc = wb.SaveToString();
Regex regex = new Regex("\\<A href=\\\"(.*)\\\".*data-sigil=\\\"logout\\\"");
MatchCollection matches = regex.Matches(fbLogoutDoc);
if (matches.Count > 0)
{
string finalLogout = string.Format("http://m.facebook.com{0}", matches[0].Groups[1].ToString());
wb.Navigate(new Uri(finalLogout));
}
}

This way the browser will not cache Facebook login cookies and next time when we intent to authenticate a new user/credentials the login screen will appear nicely. And of course, if we logout the user from a different screen as the login one, the webbrowser component can be made “invisible”


Just my simple solution for a clean windows phone facebook logout.

Wednesday, June 8, 2011

5 easy steps for a Windows Phone 7.1(Mango) to 7.0 application downgrade

 

I like to play a lot with latest beta version of Windows Phone named Mango.
I like mostly the new Windows Phone Performance Analysis tool available in Debug menu.

image

But after I tested my app, when in comes to come back to current version in market (7.0) the application platform cannot be changed back.

image

Let’s do some tricks to get it back in just five easy steps.

1. Unload the wp7 application

image

image

2. Edit the project (.csproject) files

image

change the line

    ...
<
TargetFrameworkProfile>WindowsPhone71</TargetFrameworkProfile>
...

into

    ...
<
TargetFrameworkProfile>WindowsPhone</TargetFrameworkProfile>
...
3. Reload the project
image
4. Edit Properties\WMAppManifest.xml file
image
5. Change AppPlatformVersion of Deployment node
from 7.1 to 7.0
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.1">

to

<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.0">

That’s all folks!

Saturday, June 4, 2011

“en-ro dic” windows phone app approved

Hi folks!

Just as I promised, since “en-ro dic” application was approved (quite fast I must admit), I came back with download link for those of you who wish to use it right away.
Of course you can search it also in Windows Phone Marketplace from your WP7 phone, based on keywords: “en-ro”, “romania” etc.

Have a nice time translating Romanian - English, back and forth!

en-ro dic wp7 app downloaden-ro dic

Wednesday, June 1, 2011

"EN-RO DIC" - My first WP7 app published in Marketplace to be approved

   A few days ago I proposed myself (and not only) a nice challenge. To create some small but useful applications in the languages and technologies we know the best, with a single goal.. to provide in maximum 2 days, a full featured product.
   This exercise will help me (us) in getting knowing better and efficiently the newest technologies, but also it could constitute a good base ground for a potential business start-up.
So I started first by myself with a simple application: “EN-RO DIC” – an English – Romanian Translation Dictionary, that could work offline but also online with the help of well known available online translators: Google and Bing(Microsoft).
   Unfortunately this first experience was cost me more that proposed time, and instead of 2 days I ended with 3 days (50% more with ~7-9 hours/day for research and coding). But all was for a great cause!. It was a nice experience where I learn a lot about how to improve a windows phone application overall  performance. I also had the chance to learn new tools and libraries (for example Telerik windows phone controls – because I have won a free license from them within a webinar session, I think), to work with Google and Bing translation API and various other libraries.
   Putting all together, I’m very satisfied with performance gain I succeed to obtain (~40k EN to RO words and ~70k RO to EN words), almost instant loading on the first launch or restore from tombstoning, and very fast search of the words into offline dictionary. Here are some screenshots of the final application which you will find later onto Windows Phone Market after approval process with the name “en-ro dic” (I will provide a Zune link later after approval):
dic_enro (1)dic_enro (2)dic_enro (3)dic_enro (5)dic_enro (4)
   Of course, not everything is pixel perfectly, so there will be room for improvement, but for the issues I know about, I can only blame Microsoft  :) .
   As for the future roadmap, perhaps some TextToSpeach(TTS) feature, favourite words, user proposed words, etc. There are some ideas, we only lack some time to invest. If any of you is feeling courageous to continue this project improvement, please feel free to contact me as for me this project is already doing all I have expected from it.

Feedback is always welcome!
Thank you!