Thursday 19 January 2012

How I didn't get a Windows Phone 7 for free

Some time ago Codeguru.pl (polish portal for developers, staying in very close relations with Microsoft) announced a competition called Geek Club. The basic rule was quite simple: write 5 apps for Windows Phone and get an actaul device for free. There were 2 additional requirements:
  1. In order to be accepted by Codeguru the app needs to be published on Marketplace first
  2. The app needs to make use of at least 2 listed features (like GPS, SQL CE data storage etc)
At first I didn't think about participating, mainly because of 3 reasons:
  • Unless you're a student, you have to pay 100$ to be able to publish apps to Marketplace
  • Didn't really believe in WP7 (low market share, pessimistic prognosis)
  • Writing 5 good apps seemed to be a lot of effort, especially that I don't know silverlight
However, after Maciej Grabek gave us a presentation on Windows Phone development and showed how easy it is I decided to give it a try. Also, I started to hear more & more positive opinions abut WP7 from my colleagues. The turning point was when I learned that the apps don't have to be good at all! :) They don't need to do anything useful or even funny, as long as they fulfill the 2 requirements presented above. This means I could treat the whole challenge as a good learning experience rather than a serious app development project. I didn't have to care much about functionality, like I normally would when working an application. Instead, I could focused on technical details, so it was rather a technology evaluation project.

Having said all that about good learning opportunity etc. I must admit I was still hoping to get that free phone :) But I didn't... I submitted my 5 apps (even 6 just in case) at the end of last year, but till now only 2 got checked by Codeguru team and since yesterday there are no more phones (the pool was limited). Apparently there was much more apps submitted than Codeguru team could tests.

Anyway, I'm still glad I took part in that competition. Here are most important benefits:
  • I've learned fundamentals of WP7 development, Silverlight basics, app lifecycle & Marketplace submission process
  • I know how to make use of basic features: touch screen interface interaction, GPS, Accelerometer, Microphone, Internal Storage (SQL CE), playing sounds, Bing Maps, ...
  • Got convinced that WP7 platform is actually quite nice and userfriendly
  • I can exchange the points I've earned for my apps (or will earn once Codeguru finally tests them) for other prizes like free Microsoft exams, Office Suite etc.
  • I had lots of fun :)
Now for the bad part:
  • The competition lacked transparency. Theoretically the apps to be tested by Codeguru team were put into a FIFO queue. However, there were multiple complains from developers saying that they are waiting for any response for a long time while others, who submitted their apps later, already know their results. The submission process did not leave any trace of your submission (no confirmation email, just generic message on a website) and there was no tracking system. As result people didn't know what was happening with their apps.
  • Too little testers - since I'm still waiting for my apps to be tested I assume they have not enough resources and the they didn't expect such high interest
  • Because of the competition rules the Marketplace was flooded with crappy, useless apps that were created just to get the phone (including some of my apps I must admit)
To summarize: I think we should still be grateful to Codeguru that they organized this and offered us a very motivating way to learn. Many of participants would have never learned how easy WP7 development is if there were no competition like this. However, next time they organize a similar contest they should focus on transparency and provide enough resources to manage, what they created. After all, they represent Microsoft.

PS. The other interesting fact I've learned is that the more stupid your app is, the more downloads you'll get :D

PS2. All my apps created for that competition are available on my Marketplace site. Guess which one is the most popular?

Tuesday 10 January 2012

Install PECL_HTTP on CentOS

In order to use handy HTTP extension in your PHP code you need to install it first, as it doesn't come with PHP core installation.

Below are the steps to install it on CentOS:
  1. Install PHP Pear if not installed yet:
    yum install php-pear
  2. Install GCC if not installed yet:
    yum install gcc
  3. Install cURL if not installed yet:
    yum install curl-devel
    Otherwise you'll get the following message while installing PECL_HTTP:
    configure: error: could not find curl/curl.h

  4. Start the main installation:
    /usr/bin/pecl install pecl_http
    You can use default values when answering installation questions

  5. Add the following line to /etc/php.ini file:
    extension=http.so
  6. Restart your apache server so the extension can be loaded:
    httpd -k restart
You should now be able to use it. hope I saved you some time :)

Saturday 7 January 2012

WP7 location services policy check

Lately I've been playing with Windows Phone 7 app development. I submitted several free apps to Marketplace and had no troubles getting the apps certified and published. Not until I created an app that uses Location Services. The app failed to pass the certification stage with the following comment:

Your application failed the Marketplace prohibited application policy check. Please review the above policy, notes below (if applicable), update and re-submit your application.

To be honest, up to that moment I haven't been paying enough attention to certification requirements. After I received that notification I dived into the details and realized that the policy for application that use location information is quite strict. This can be easily justified by privacy protection etc.

How to pass location services policy check?

Knowing that my application is missing something I decided to fix it. I started with a lecture of Microsoft official Application Policy description. I really recommend you familiarize yourself with those rules before you start any WP7 app development.

The requirements regarding location policy I didn't fulfill are covered in Section 2.7. Once you read those you have a theoretical understanding of what you need to do. However, how does it look like in practice? I wasn't able to find a full example of an application that did pass the certification. Instead, I only found some general advices that I followed.

Below are 3 changes that I introduced to my app to make it pass the certification process
  1. Notification message
    Add a notification message on application start that will inform the user that your app is using location services. Give the user a choice to not allow that. The sample C# code for that could look like this:
    // Check if 'allow' setting already set
    bool? allow = null;
    if (PhoneApplicationService.Current.State.ContainsKey("allow"))
    {
    allow = (bool)PhoneApplicationService.Current.State["allow"];
    }

    if (allow == null)
    {
    // 'allow' setting not set yet (i.e. it is first page load)
    // Display the confirmation question
    var result = MessageBox.Show(
    "This application uses your location. Do you wish " +
    "to give it permission to use your location?",
    "User Location Data",
    MessageBoxButton.OKCancel);

    // Save answer so you can access it on other pages
    allow = (result == MessageBoxResult.OK);
    PhoneApplicationService.Current.State["allow"] = allow;
    }

    if (allow)
    {
    // Initiate your app normally
    }
    else
    {
    // Display message about limited functionality of your app
    // Disable elements that can cause usage of location services
    }
  2. Additional setting
    Add an additional setting item to your app that will allow the user to turn access to location services on and off. If your app doesn't have settings page yet you need to create one. The setting can use a simple checkbox. It should also reuse the state information we saved on application start. XAML code for that could be as simple as that:
    and your code behind:
    private void Page_Loaded(object sender, RoutedEventArgs e)
    {
    // Set checkbox value on page load
    bool allow = false;
    if (PhoneApplicationService.Current.State.ContainsKey("allow"))
    {
    allow = (bool)PhoneApplicationService.Current.State["allow"];
    }
    ckbAllow.IsChecked = allow;
    }

    private void CheckBox_Click(object sender, RoutedEventArgs e)
    {
    // change the saved value when checkbox is clicked
    PhoneApplicationService.Current.State["allow"] =
    ((CheckBox)sender).IsChecked.Value;
    }
  3. Policy page
    The last thing left to do is to create an additional page that describes to the user what the app exactly does with the location information it gathers. Inform the user if you save it or send it somewhere etc. The policy page can be linked from the main app page or available via application menu. The latter could be implemented like that:
    // Main page constructor
    public MainPage()
    {
    InitializeComponent();

    // Add an Application Menu Bar
    ApplicationBar = new ApplicationBar();
    ApplicationBar.IsMenuEnabled = true;
    ApplicationBar.IsVisible = true;
    ApplicationBar.Opacity = 1.0;

    // Add Policy menu item
    ApplicationBarMenuItem policyItem =
    new ApplicationBarMenuItem("location services policy");
    policyItem.Click += new EventHandler(policy_Click);
    ApplicationBar.MenuItems.Add(policyItem);

    // Add other menu items e.g. Settings
    }

    void policy_Click(object sender, EventArgs e)
    {
    // Show the policy page called Policy.xaml
    this.NavigationService.Navigate(
    new Uri("/Policy.xaml", UriKind.Relative));
    }
That's it. The 3 changes above worked for me and my app passed the certification process. Good luck with your apps!