Using Nokia Ad Exchange on Windows Phone 8

 

Following on from the last two articles :

  1. Adding a TimeStamp in Azure Mobile Services
  2. Semi-Transparent Panoramic Background Images

this article came about as a result of new Apps I have been developing / enhancing for Windows Phone 8.

In the past I have used Microsoft’s’ own Advertising SDK but for I thought it would be interesting to try out Nokia’s new advertising SDK*.  Further down the line I will blog some results and contrast these with those resulting from the use of the Microsoft SDK.

Getting started is easy, sign up and download the SDK from this page:

https://nax.nokia.com/iamp/nokia/publisher/dashboard#ui-tabs-5

I followed the instructions on the developer wiki for Windows 8 Phones here:

Windows Phone 8 SDK guidelines

This will take you through the three basic steps:

  1. Adding the SDK to your project.
  2. Adding required references and capabilities.
  3. Displaying ads within the application.

The approach looks to be marginally simpler than the Microsoft SDK though both are very easy to implement.

I opted to Add everything using code:

image(Click to enlarge)

I’m not sure about the value of the optional parameters but decided to add them anyway

NB Note the reference to App.NokiaID – this is the App ID that is given when you add an App in the Ad Exchange Web Site below (I simply declared it in App.Config for tidiness sake).  The ID should look something Like:

“YourCompany_YourApp_WP”

image

Payments are monthly and are triggered as soon as you go over the $200 threshold (I have to say that probably equates to never for me but hey, lets’ not be too pesimistic!)

And that is all there is to it.

If you would like to see an example of the Ads that the App serves up check out one of the following Apps (make sure you select the free trial)


1. Which Diet?

2. Fishing Tips


Have fun!

* Which is actually a badged version of the Ad SDK from Inneractive.

Transparent Panoramic Background Images

 

I have used images for the panoramic control to good effect in phone applications in the past but one issue I have always had to manage is ensuring that the image works equally well  with both the light and dark themes.  With skill it is sometimes possible to use a single opaque image to good effect.  It is also possible to check which theme is in operation on start-up and set the image programmatically accordingly (not covered by this post)

When working on my latest ‘App Builder’ inspired App ‘Fishing Tips’ I suddenly had the thought of using a semi-transparent background image (instead of a ‘compromised’ opaque image).  I commonly use “Paint.NET” for any image related work and so took a little time out to search for a suitable plug-in that might help me to test out my idea.

I found a suitable plug in here and proceeded to test out my theory:

Here are the results:

image
Applying the effect in Paint.NETimage

image
Before and after transparency application.

image

image
Within the App using Light and Dark themes.

As you can see the same image works equally well with either theme selected
(Note to self: it looks like some of those images need re-aligning?)

BTW The XAML used for the Panoramic Background image is as follows:

image

Someone also pointed out that the same result can be achieved with a completely opaque background image by setting it’s opacity to 0.25 – which I must admit gave me a ‘slap  forehead’ moment.


NB You can download ‘Fishing Tips’ once it has been published <here>

Controlling caching of BitMapImage under WinRT

By default Bitmap Images are cached by WinRT with no intervention required by the developer.  Often times this is a good thing but there are some occasions where this is undesirable.  Although there doesn’t appear to be any obvious control in the API reference I have found that adding a dummy querystring to the BitMapImage source filename reference does the trick and also can offer precise control over the length of caching required (if any) .

Here is how I currently manage caching in a project and limit it to being refreshed once every hour:

In My App.Config I set up a static variable:

public static String CacheOffset = "?Cache=" + ;
System.DateTime.Now.DayOfYear.ToString() + ;
System.DateTime.Now.Hour.ToString();

When I populate my local collection I then use something like:

String MyImagePath=”MyBitMapImage.png”+App.CacheOffset;

This way the images are cached for the duration of the users WinRT session and also up to an hour beyond the initial population of my data collection.   Obviously I can vary this duration using different parameters from the current system date and time.  For instance the following would ensure that effectively no caching is carried out between user sessions:

public static String CacheOffset = "?Cache=" + ; System.DateTime.Now.Ticks.ToString() ;

If you wanted to update the image during a session then it would simply be a case of populating your image source using a different ‘virtual cache’ value for CacheOffset.

I suspect there may be better ways to achieve the same objective but for now this works for me.

Tip – Windows Phone Mango Training Videos

There are a great series of training videos available from those nice people at MSDEV at http://www.msdev.com/Directory/SeriesDescription.aspx?CourseId=174   If you get the chance (and you have the bandwidth) I would urge you to watch them online now.

However, if you are like me (bandwidth and time challenged) then you might want to download them for viewing later.  Two options present themselves:

The first is to go into the download page of each video and download them in your browser (that can be a little time consuming).

The second is the essence of this tip and involves using a third party application called “free download manager”

image

I use this app all the time for batch downloading of all sorts of files.  One of the useful features that I often take advantage of is the option to download a list of files from the clipboard (CTRL+SHIFT+V).

For this particular series I noticed that the urls for all the videos were consecutive, so I simply copied the first one to notepad and replicated the rest of the links myself:

http://www.msdev.com/Directory/Attend.aspx?eventId=1999
http://www.msdev.com/Directory/Attend.aspx?eventId=2000
http://www.msdev.com/Directory/Attend.aspx?eventId=2000
http://www.msdev.com/Directory/Attend.aspx?eventId=2001
http://www.msdev.com/Directory/Attend.aspx?eventId=2002
http://www.msdev.com/Directory/Attend.aspx?eventId=2003
http://www.msdev.com/Directory/Attend.aspx?eventId=2004
http://www.msdev.com/Directory/Attend.aspx?eventId=2005
http://www.msdev.com/Directory/Attend.aspx?eventId=2006
http://www.msdev.com/Directory/Attend.aspx?eventId=2007
http://www.msdev.com/Directory/Attend.aspx?eventId=2008
http://www.msdev.com/Directory/Attend.aspx?eventId=2009
http://www.msdev.com/Directory/Attend.aspx?eventId=2010
http://www.msdev.com/Directory/Attend.aspx?eventId=2011
http://www.msdev.com/Directory/Attend.aspx?eventId=2012
http://www.msdev.com/Directory/Attend.aspx?eventId=2013
http://www.msdev.com/Directory/Attend.aspx?eventId=2014
http://www.msdev.com/Directory/Attend.aspx?eventId=2015
http://www.msdev.com/Directory/Attend.aspx?eventId=2016
http://www.msdev.com/Directory/Attend.aspx?eventId=2017

So it was then simply a case of copying the above links to the clipboard (Select All then CTRL+C), firing up “Free Download Manager” and using CTRL+SHIFT+V to begin the downloads in the background.  I can now get on with other work until I am notified that the downloads are complete.  I hope you find this tip useful.

You can download Free Download Manager from here: http://fileforum.betanews.com/detail/Free-Download-Manager/1090197761/1

And just in case you are a little lazy, here are the titles of the videos (hosted by none other than Adam Kinney):

MSDN How Do I: Use the new features in the Window Phone Emulator and Tools?
MSDN How Do I: Use the Windows Phone Profiler?
MSDN How Do I: Work with the Execution Model?
MSDN How Do I: Use the new Bing Tasks?
MSDN How Do I: Access Contacts and Appointments Data?
MSDN How Do I: Use Toast, Tile and Raw Notifications?
MSDN How Do I: Update Tiles and Use Secondary Tiles?
MSDN How Do I: Use the System Tray features?
MSDN How Do I: Use the Search Extensibility features?
MSDN How Do I: Combine Silverlight and XNA?
MSDN How Do I: Programmatically Access Camera Features?
MSDN How Do I: Create an Augmented Reality Application?
MSDN How Do I: Use the WebBrowser Control?
MSDN How Do I: Use HTML5 in the WebBrowser Control?
MSDN How Do I: Use the RichTextBox control?
MSDN How Do I: Localize an Application?
MSDN How Do I: Work with a Local Database?
MSDN How Do I: Communicate with Sockets?
MSDN How Do I: Access OData Resources?

[tweetmeme only_single=”false”]