Wednesday, April 11, 2012

Windows Phone - Monetizing your Apps

Hello

There several ways to generate money from your application
  1. Use advertisement in your application
  2. Price your application from 0.99$ to 499$
  3. Provide a free trial and offer the user an option to upgrade to the full application for fee

The best approach in my view is the following : free app with advertisement + an option to remove advertisement for a fee. In this way you make money both directions and reach two markets : one that is not willing to pay and one that is willing to pay.

Use advertisement in your application

There are a lot of ad providers

  • Support about 20 countries (Israel not included)
  • Open
  • Open
  •  Payment Bank\PayPal
  • Open
  •  Payment Bank\PayPal
  • Open
  • Promote your application 
  • Open
  •  Payment Bank\PayPal
  • Open
  •  Payment Bank\PayPal

Look here how to register at these ad providers


Basically some providers may be useful in U.S. but not in Europe.
It may be also useful to use few providers at a rotation to get better Fill rate.

Since every provider has it's own API it would be nice to have unified interface - this is exactly what is done by a codePlex project name "Unified Ad Control for Windows Phone" which supports all above providers.

Source sample
TestAd_NK.zip


This sample use AdControl with many ad providers.
The sample use two AdProviderStrategy types

  • default - AdRotate.
  • RemoteAdProviderStrategy



Note that after i have create the new Windows Phone Silverlight project i installed a "Unified Ad" package into it. This was done in two steps :

  • Download Nuget here and install it (unless it is already installed).

PM> Install-Package wpunifiedad -Version 0.1.0

This will install all packages needed into your project.(You do not need do it for the attached zip)

SimpleAdRotate.xaml

Three Ad providers are used here :
  • AdDuplex
  • MobFox
  • Smaato
Other providers : PubCenter,AdMob,MillenialMedia,InnerActive are remarked under AdProviders tag

But you MUST replace the Id strings circled to the Id you got when registered to these ads providers.


The default AdProviderStrategy is used here - AdRotate  .This means that providers are arranged in list and are accessed for ad. If they do not provide an ad then the next provider will be accessed.



RemoteAdProviderStrategy.xaml

Three Ad providers are used here :
  • AdDuplex
  • MobFox
  • Smaato
Other providers : PubCenter,AdMob,MillenialMedia,InnerActive are remarked under AdProviders tag

But you MUST replace the Id strings circled to the Id you got when registered to these ads providers.

The RemoteAdProviderStrategy is used here. It has two important properties :

  • LocalProviderSettingsUri
  • RemoteProviderSettingsUri
The LocalProviderSettingsUri access Ads/AdSettings.xml. It is accessed in case the remote setting is not accessable

The RemoteProviderSettingsUri access  a remote Uri. This looks very powerfull because you can change this file even after the app is in the marketplace.



AdSettings.xml

Probability is the chance that a provider will be used.
In my case - English US the second AdCountryDescriptors will be used i.e. MobFox has the best chances to be picked as ad provider


Update the Ids you got in SimpleAdRotate.xaml, click the button "Simple Ad Rotate " to produce :


Note that ONLY one ad provider appears, this is because of the test mode which cause every ad provider to provide an ad thus no need to go to the other ad provider in the list. In actual application this should be OK.

Update the Ids you got in RemoteAdProviderStrategy.xaml, click the button "Remote Ad Provider Strategy"  to produce :


This is Smaato ad, click it and see what happens

Later you will see


This MobFox ad, click it and see what happens

And later

This  AdDuplex ad, click it and see what happens

Remarks :

  • The order of ad appearance might be different


Price your application from 0.99$ to 499$
Done as part of the application submission

Provide a free trial and offer the user an option to upgrade to the full application for fee
As far as i know this option does not exist.
You can have the application without ads in the paid area and the same application with ads in the free area. This looks like we need two applications or at least one application with a define.


Nathan

Monday, April 9, 2012

Windows Phone - Globalization and Localization

Hello

You want to write your application for more then one language ?
This post will help you understand how to do it.


Localized application 

Localized application is one that is translated into few languages.

There are few things you can localized in your application :

  • App Text - buttons, menus, help, ..
  • App Description - seen in the marketplace
  • App Title - appears in the application list and application title
  • Appllication Bar Text - in case you have application bar


It is possible to publish an English application to all markets but localization will attract also non English users.

Localize the App title
The application title appears in the application list :




And in case it is pinned to the application tile :




A. Create a language resource dll project

  1. On the File menu, point to New and then click Project.
    The New Project dialog appears.
  2. In the left pane, click Installed Templates, expand Visual C++ and then click Win32.
  3. In the list of project types, click Win32 Project.
  4. In the Name box, type AppResLib.
  5. In the Location box, enter a location for your project.
    Note Note:
    For the purposes of this procedure, you can create the AppResLib project anywhere.
  6. Click OK.
    The Win32 Application Wizard appears.
  7. In the left pane, click Application Settings.
  8. Under Application type, select DLL.
  9. Under Additional options, select Empty project.
  10. Click Finish.
    The new DLL project is created and opens in Visual Studio.
  11. In Solution Explorer, select the new DLL project.
  12. On the Project menu, click Properties.
    The Property Pages dialog appears.
  13. In the left pane, expand Configuration Properties, expand Linker, and then click Advanced.
  14. Select the No Entry Point property, click the drop-down arrow to the right of the property value, and then click Yes (/NOENTRY).
    Note Note:
    /NOENTRY prevents the linker from linking a reference to _main into the DLL; 
    this option is required to create a resource-only DLL.
  15. Click OK.
  16. Save and build the project.


B. Create a language neutral resource string for your application
  1. In Solution Explorer, select the new DLL project.
  2. On the Project menu, click Add Resource.
    The Add Resource dialog appears.
  3. In the Resource type list, select String Table and then click New.
    The resource string table opens.
  4. Create two resource strings with the following properties.
    ID - AppTitle , Value - 100 , Caption - The language-neutral name of your application 
    to be displayed in the application list


    ID -  AppTileString , Value - 200 , Caption - The language-neutral name of your application to be deplayed in the application Tile when pinned to Start.











  5. Save and build the DLL project.
  6. In Windows Explorer, locate the file AppResLib.dll that you just built.
  7. Copy the file AppResLib.dll to the directory that contains your Windows Phone application project file.


C. Create the first specific language resource string for your application

  1. Edit the resource strings, setting the properties as follows.
    ID - AppTitle , Value - 100 , Caption - The language-neutral name of your application 
    to be displayed in the application list


    ID -  AppTileString , Value - 200 , Caption - The language-neutral name of your application to be deplayed in the application Tile when pinned to Start.





  2. Save and build the DLL project.
  3. In Windows Explorer, locate the file AppResLib.dll that you just built.
  4. Rename the DLL file to AppResLib.dll.0409.mui.
  5. Copy the file AppResLib.dll.0409.mui to the directory that contains your Windows Phone application project file.

D. Create additional language resource string for your application

Repeat the previous procedure, renaming the DLL files using the information in the following table. Each DLL file name has the formatAppResLib.dll.[locale ID].mui.
Note Note:
For a full list of which display languages are supported on which version of 
Windows Phone, see Culture and Language Support for Windows Phone. and also 

E. Using the localized strings in your app


  1. In Solution Explorer, select your Windows Phone application project.
  2. On the Project menu, click Add Existing Item.
    The Add Existing Item dialog appears.
  3. Select the AppResLib.dll file and all the AppResLib.dll.*.mui files, and then click Add.
    The files are added to your Windows Phone application project.
  4. In Solution Explorer, select the imported DLL files, and in the Properties window, set the Build Action properties to Content.
  5. In Solution Explorer, expand Properties and then double-click WMAppManifest.xml.
  6. Modify the WMAppManifest.xml file to use the AppTitle resource string from the satellite DLLs for the application title used in the application list. The code is highlighted in the following (you need to change only "Title") :
    <App xmlns=""
         ProductID="{product id}"
         Title="@AppResLib.dll,-100"
         RuntimeType="Silverlight"
         Version="1.0.0.0"
         Genre="apps.normal"
         Author="author"
         Description="description"
         Publisher="publisher">
    
    
  7. Modify the WMAppManifest.xml file to use the AppTileString resource string from the satellite DLLs for the application title used in the application Tile. The code is highlighted in the following  (you need to change only "Title") :
    <PrimaryToken TokenID="WindowsPhoneApplicationToken" TaskName="_default">
      <TemplateType5>
        <BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI>
        <Count>0</Count>
        <Title>@AppResLib.dll,-200</Title>
      </TemplateType5>
    </PrimaryToken>
    
  8. Save and build the Windows Phone application.



F. Test the localized title

  1. On the Debug menu, click Start debugging.
    The application opens in the emulator.
  2. Click the Start button, and then click the arrow icon.
    The application list appears.
  3. Click and hold your application title until the context menu appears, and then click pin to start.
  4. Click the Start button, and then click the arrow icon.
    The application list appears.
  5. Click Settings, and then click region & language.
    The settings appear.
  6. Click Display language and then click one of the languages. 
    You automatically return to the region & language settings page.
  7. Click Tap here to accept changes and restart your phone.
    The emulator changes the setting, and returns to the Start screen.
    Verify that the language of the title that appears on the application Tile matches the language setting that you selected.
  8. Click the arrow icon.
    The application list appears.
    Verify that the language of the title that appears on the application Tile matches the language setting that you selected.
  9. Repeat the above steps to test the other language resource strings that you created.
    Note Note:
    The placement of each UI element on the screen remains the same regardless of the
     display language. Note the placement of UI items in your primary language so that 
    you can easily change between display languages.



Source Sample
Localization_NK.zip


This sample support three languages : English , Spanish and Frances.
Each language has a matching file :
English - change AppTitle\AppTileString to Localization in AppResLib.dll.0409.mui
Spanish - change AppTitle\AppTileString to  localización  in AppResLib.dll.0c0a.mui
Frances - change AppTitle\AppTileString to localisation in AppResLib.dll.040c.mui

Do not forget to add these files to the project and changes their "Build Action" property to Content




Under Setting -> region + language ->Display Language change to Espanol


The application list has changed to :



Same goes for application tile :





Localize the App text


Specify the Natural Language
The natural language is set according to the language you have chosen downloading the SDK:


Now every new Windows Phone application default language will be the same.

You can change the default language via the Project_>Properties->Assembly Information->Neutral Language





Create Resource File for Each Language


A. Adding resource files to a project and enabling localization support
All localizable resources should be moved to a resource file.
  1. Add a resource file for the default language of your application.
    1. Open the project in Visual Studio.
    2. Add a resource file. In Solution Explorer, right-click on the project name, click Add and click New Item.
    3. In the Add New Item dialog box, choose Resources File and re-name the file if desired. For example, you could re-name the file as AppResources.resx. This file will contain the resources for the default language for the application.
    4. Identify strings in your application and add them to the resource file. You can input a name, a value, and an optional comment for each string.
      • The name must be unique. Make it as descriptive as possible.
      • The value is the string that will be displayed to the user in the application.
      • The comment is optional, but it is helpful for translators, especially in large resource files with many strings.
  2. Add a resource file for each additional language that the application will support. Each resource file must contain the correct culture/language name, as described in Culture and Language Support for Windows Phone.
    For example:
    • For the culture Spanish (Spain), use AppResources.es-ES.resx.
    • For the culture German (Germany), use AppResources.de-DE.resx.
    Note
    You need to complete this step only for additional languages. For example,
     if your default language is English (United States) and you have added the
     strings for that language into the default language resource file, 
    you should not create an additional resource file for "en-US."
  3. Define the default culture that the application will support:
    Important note Important Note:
    By default, the Neutral Language is set to the default culture in Visual Studio. 
    If your application targets a different culture than the default culture in
     Visual Studio, you will need to complete the following steps.
     If you are not targeting a different culture, verify with
     the following steps that the correct Neutral Language is set.
    1. In Solution Explorer, right-click the project name, and click Properties.
    2. Under the Application tab, click the Assembly Information button.
    3. In the Neutral Language list, select the default culture. This identifies the language of the strings in the default resources file. For example, if the default resources file is named AppResources.resx, and the strings in that file are English (United States) language strings, you would select English (United States) as the Neutral Language for the project.
  4. Close the project and open the project file (<project name>.csproj) in a text editor. Locate the <SupportedCultures> tag and add the names of each additional culture (language) your application needs to support. You should have an entry for each .resx file added to the project).
    Separate the language names using a semicolon, and only add the additional culture names. For example, if an application uses English (United States) for its default culture, but the application also supports German (Germany) and Spanish (Spain), you would update this tag as follows:
    <SupportedCultures>de-DE;es-ES;</SupportedCultures>

B. Replacing hard-coded strings with strings in a resource file
Re-open the project to replace the hard-coded strings with strings in a resource file.
  1. In Solution Explorer, open a resource file and select Public from the AccessModifier list box at the top of the pane. Repeat this step for each resource file in your project.
  2. Define a class with a property that points to the resources 
  3. Open your App.xaml file and update <Application.Resources> section
  4. Perform binding from code to the resource
  5. Build your application – it will now build as a multilingual application and display a user interface according to the language settings of the phone.




Source Sample
Localization_NK.zip


This sample support three languages : English , Spanish and Frances.
It has one button with Click text which is supported in these 3 languages

Following step A - Adding resource files to a project and enabling localization support and B.1 we end up with three files :


AppResources.resx - the default English language




AppResources.fr-FR.resx - the French language file


AppResources.es-ES.resx - the Spanish language file



Notice the update to the project to reflect supported languages




Now we continues with B -  Replacing hard-coded strings with strings in a resource file


Define a class LocalizedStrings.cs

This class actually provide access to class AppResources which was created when AppResources.resx was created. It should not come as surprise that class AppResources has the following property :


Add a resource type LocalizedStrings to App.xaml as follows :

Add a Click Button and bind it to the strClick




Run the application to produce :


Now change the display language to Espaniol , after complete boot and running the application :

The text matches espaniol



Localize the Application Bar
This is done using the same resource file used for localizing Text, however binding is not possible sience Application Bar is not Silverlight control.


Source Sample
Localization_NK.zip

The sample add application bar with one button and one menu item.

Add ApplicarionBarButtonText and ApplicarionBarMenuItemText strings to :

  • AppResources.resx
  • AppResources.fr-FR.resx
  • AppResources.es-ES.resx


MainPage.xaml.cs


MainPage.xaml


Change IsVisible to True


Run the application to produce :



Now change the display language to Espaniol , after complete boot and running the application produces :





Localize the App description
Once you have finish creating your application you submit it to App Hub. App hub detect which languages you support (via the SupportedCultures tag which you have updated) and will prompt you to enter a description for every languages which you support :



Make sure the description language match the supported language

Globalized application 

A globalized application displays e.g. dates and money in a way that is familiar to the user. E.g. some countries uses $ other uses Euro.

Globalization of your application can be done via the class CultureInfo.


Source sample
Globalization_NK.zip

The application displays :

  • Culture
  • Date
  • Currency


MainPage.xaml



MainPage.xaml.cs



Run the application to produce :


Now change the display language to Espaniol , after complete boot and running the application produces :


Notice the change in all fields.
Note that once the user has changed the display language the date format is changed automatically. The currency on the other hand should be taken from CultureInfo


Nathan

Thursday, April 5, 2012

Windows Phone - SkyDrive

Hello

SkyDrive is a microsoft free cloud storage.

You can perform Read\Write\Delete over Directories\Files\Albums. Sharing is also possible

Download the Live SDK


SkyDrive is actually a part of Live Connect which consists also :

  • Hotmail - mail
  • Messanger - chat
  • Windos Live ID -  authentication

Live Connect use standard protocols such as HTTP, OAuth 2.0, JSON, XMPP and REST.

The Live Connect  REST API exchange info between application in JSON format.


Basically you have to sign in to get authenticated via your Live ID. This can be done via SignInButton.

Important properties of SignInButton :

  • ClientID - The ID of the registerd application. You get this from Windows Live My Apps
  • Scopes - Specify the type of permission you grant to operate on your SkyDrive e.g.  wl.skydrive_update grant read\write access to the user files
  • RedirectUri - This is the page that the user is directed after clicking the SignInButton. https://oauth.live.com/desktop is used for mobile application
  • Branding - This is type BrandingType. It specify the display icon
  • TextType - Specify the SignInButton Text
  • Session - Identify the session for the authenticated user

Important event of SignInButton :



After the authentication phase via SignInButton you are able to create an object type LiveConnectClient.

LiveConnectClient expose an end poin tof the Live Connect web service.
Methods  of LiveConnectClient are helper function for making calls to REST API


When your application makes a GET request for an object via the methods of LiveConnectClient, the Live Connect REST API returns the requested info as a JSON formatted structure.
When  your application makes a POST or PUT request via the methods of LiveConnectClient, the Live Connect REST API requires the submitted info to be a JSON formatted structure



Source Sample
SkyDrive_NK.zip

Hit the link to produce

Now enter the application name.- SkyDrive_NK and click accept to produce :


Click on "Application Setting Page"  and change "Mobile client app" to Yes



Add reference to Microsoft.Live.Controls and Microsoft.Live :



MainPage.xaml

The Application has three buttons :

  • SignInButton - sign in the user
  • Create File In Isolated Storage - create file to be uploaded
  • Upload File - uploaded the file in the isolated storage to SkyDrive

Do NOT forget to change the ClientId accordoding to what you got from Windows Live as described before

MainPage.xaml.cs

The following handles the sign in.

The following handles uploading the file a.txt from isolated storage to SkyDrive.
Notice that UploadAsync is used and after it's completion client_UploadedCompleted will be called.


Run the application to produce :


Click on the Sign In button to produce :


Enter Windows Live ID e.g. your hotmail account and password to produce :


Click the Yes button to produce :



Click the button "Create File In Isolated Storage" to create a file in the isolated storage :


Click the button "Upload File" to copy the file from isolated storage to your SkyDrive


Now open your SkiDrive (https://skydrive.live.com/) and see that the file got there



Nathan