Tuesday, January 14, 2014

Custom URIs added to I'm Here App

,
I took a few moments to add custom URI launchers for my I'm Here app on Windows Phone so it could be used in Rob Irving's Car Dash app.  It was a really quick add to the app, however the one are I found to be a pain was testing it.  I actually had to write another phone app to test it. Not that it was a chore, just didn't consider that when I started, I made an assumption I could've just typed i the URI in Internet Explorer or mocked an SMS message like you can in iOS.

If you have a Windows Phone App that offers functionality that other apps can use there is no reason not to offer custom launchers.  It takes about an hour total development time, and the benefit can more than just adding the functionality.

In my case, one I learned how to do it. Two, I get free marketing from another very successful app. Make sure you document your URI on the Nokia page here to let every other developer know for extra exposure. And finally, made a nice connection in the developer community.  Who knows, maybe the next big thing will happen when Rob and I team up...

If you want to use I'm Here in your app here is the simple launcher URI code to do so.

// launch the app
await Windows.System.Launcher.LaunchUriAsync(new Uri("imhere:"));
// launch the app and share location via SMS

await Windows.System.Launcher.LaunchUriAsync(new Uri("imhere://share/text"));
// launch the app and share location via Email

await Windows.System.Launcher.LaunchUriAsync(new Uri("imhere://share/email"));
// launch the app and share location via Social Apps

await Windows.System.Launcher.LaunchUriAsync(new Uri("imhere://share/social"));

// launch the app and share location via WhatsApp application
await Windows.System.Launcher.LaunchUriAsync(new Uri("imhere://share/whatsapp"));


Be sure to checkout my apps and the other links below to take advantage of the custom URIs in you own apps.

Rob Irving on Twitter
Nokia URI Association Schemes List
URI associations for Windows Phone - How To
Reserved file and URI associations for Windows Phone 8
Read more →

Thursday, January 2, 2014

Microsoft MVP - ASP.NET

,
This year started off with a nice surprise, an email with the subject "Congratulations 2014 Microsoft MVP!"

I am humbled and excited, as this is the first time for me, and as always to be a part of such a great community. I enjoy the time I spend at community events, speaking to other developers and hearing their challenges, ideas and what great projects they are working on.

ASP.NET is the category of my award, and although most know me for some the Windows Phone work I have done; Web API, MVC, and JavaScript/TypeScript is where I have spent a majority of my time. Mobile is as much about the back end services as it is about the front end.

2014 is going to be another great year.  I am already putting together my speaking schedule, working on new material and projects and can't wait to see the new stuff from the other new and renewed MVPs.

Thanks to all of my supporters in the community! Especially those in Florida who I get to see on a regular basis.
Read more →

Friday, November 22, 2013

Being a successful mobile developer - Windows Phone, Marketing & Xamarin

,

Why Windows Phone?

This is not a new question, but a question or topic that I get involved a lot.  Why do you have a Windows Phone? Why do you build apps for that platform? You should be learning Java and Objective C and putting your apps on iOS and Android; that's where the users are.

That is the message from the media, family, tech pundits and co-workers. And the numbers say that as well; the latest report shows that Android holds a ridiculous global market share of 80%, Apple with 12% and Windows Phone at 4% respectively.  So why should I build an app for Windows Phone first?

Its about visibility.

Visibility

Apple has more than 1 million apps on the iOS platform and Android just over 800,000. It is virtually impossible without spending an enormous amount of time, money and or energy getting an app exposure to the user base.  However, through programs like Nokia's DVLUP you can manage to get very visibility in the marketplace, increased reviews and downloads and through the combination of all of these. Revenue will begin to climb. Now, there is some learning to be done by the developer when it comes to monetizing your app; I won't go into the various strategies as there have been many workshops/articles/blogs published so definitely look into those.

Building a Brand / Marketing

Build it and they will come is not a marketing campaign strategy! I'm pretty involved in the community and talk with a lot of developers, read quite a few email and message board threads about how they have a new app for this or that...please review, download etc.  But that is the last place I see it ever mentioned.

Here are a few suggestions:

  • Build a Facebook Fan Page - it's free
  • Azure Websites - every subscriber gets 10 free site, build one for your app
  • Blog about the technology you used in your app, why you chose to do it. 
  • Contact Media outlets about your app - wpcentral.com, wmpoweruser.com
  • Use social media to your advantage - twitter, Facebook, LinkedIn, Google+, Instagram (yes) & learn what a hashtag (#) is and use those to your advantage. If you don't know ask a teenager.

Design

Now none of the above will matter if your app is a battleship grey page with black comic sans font. Spend some time on design.  Now I know, not all developers are good designers. Guess what? Not all designers are good developers.  Find a friend who knows Photoshop, team up! There is this really cool online collaboration tool - Team Foundation Service that's free for up to 5 users, collaborate on a project and make it happen.

Build with Other Platforms in Mind - Xamarin

Now that you have a great idea, either put together a great design or found a friend & have a marketing strategy.  Build your app with the correct tools and architecture so when you have Android and iOS users wanting it, you can respond in a reasonable amount of time.

Xamarin and Microsoft have teamed up to bring a closer integration in Visual Studio 2013 to allow you to create native iOS and Android applications (not HTML5 & JavaScript) using C# and Portable Class Libraries. Thus maximizing your code reuse.

Microsoft also just announce full Azure Mobile Services support for Xamarin.

I will be blogging more examples, in the meantime visit www.xamarin.com and follow @xamarinhq & @jamesmontemagno (Xamarin Developer Evangelist) on twitter.

Please feel free to contact me via twitter @spboyer concerning xamarin, portable class libraries, windows phone development, windows 8 development or anything.
Read more →

Friday, November 15, 2013

Presenting Azure Mobile Services @ DVLUP Day Tampa 11/16/2013

,
Nokia, through its DVLUP program, is putting on DVLUP day in various cities from Nov. 16 - Dec 6.  I'll be in Tampa on the 16th of November presenting Azure Mobile Services.

I'll give an overview of:

  • Getting Started
  • Push Notifications
  • Visual Studio 2013 Tools for Azure
  • General Q & A


I will also be around all day if you have any questions about Portable Class Libraries or Advanced features of Azure Mobile Services such as complex data types, authentication, etc.

Event Summary

Spend a day with two of our top Nokia Developer Ambassadors, Bill Reiss (@billreiss) and Atley Hunter (@atleyhunter). Together, Bill and Atley will guide you through the process of publishing your apps to the Windows Phone Store - either from scratch, or porting from iOS or Android.

Whether you’re a first-time developer, or a seasoned pro who wants to know more about Windows Phone, this event is for you.

If you are in the Tampa Area, there is still space so sign up! There are other dates and locations available and they can be found on the DVLUP site (http://www.dvlup.com/Events/138).

You will need to have your DVLUP account ID. If you haven’t signed up already, sign up today at  www.dvlup.com

 To win a device you need to complete one of these DVLUP challenges:

http://www.dvlup.com/Challenge/32

http://www.dvlup.com/Challenge/125

Your app must be published within 14 days of your event to win.

If you are attending, be sure to tweet and use the hashtag #DVLUPday #tampa and follow @dvlup

Read more →

Saturday, August 24, 2013

Azure Mobile Services & Portable Class Libraries - Part 2 Authentication Cont'd

,
In Part 1 I covered a simple implementation of the Authentication feature and portable class libraries from the Azure Mobile Services SDK.  However, as mentioned in the "Good & Bad So Far" section; there is not a whole lot of code reuse other than the Azure endpoint and secret key.  Let's refactor a bit by adding some interfaces, conditional compile statements and the MVVM Light Event Bus to help the same solution operate cleaner.

The "after" code for part one is available here.

Building Our Core

PortableAzure.Core is our Portable Class Library that is being shared with the Windows 8 and  Windows Phone project in the attempt to reuse as much code as possible.  However, as mentioned in Part 1 the authentication portion of the Azure Mobile Service SDK is a platform specific implementation due to the UX pieces of that component and how it is presented varies.

Platform Adapter (PlatformAdapter.cs)

In the Services folder, add a new class called PlatformAdapter.cs.  This is an abstract class that will be used as the base class for the platform specific implementation.

    public abstract class PlatformAdapter
    {
        public static PlatformAdapter Current { get; set; }
        public abstract IIdentity Identity { get; }
    }

Identity (IIdentity.cs)

Add a new Identity interface, IIdentity.cs to be used as the implementation to execute the Authenticate method as well as store the MobileServiceUser upon logging in.

    public interface IIdentity
    {
        void Authenticate();
        MobileServiceUser User { get; set; }
    }


 Messages

Add a Messages folder to the root and a class called LoginMessage.cs to newly created folder.

Using the Event Bus from MVVM Light, a LoginMessage will be sent from the platform specific MainPage.xaml then subsequently handled in the MainViewModel.  The LoginMessage is just an empty class at this point.

    namespace PortableAzure.Core.Messages {
        public class LoginMessage { } 
    }

Adding Adapters to the Platforms

On each plaftform we need to now inherit from the PlatformAdapter.cs class in the Services namespace from the Core library as well as implement the IIdentity interface thus replacing the code shown in part one with this code.

Windows Phone

Add an "Adapters" folder to the root of the project and then a Platform.cs class which inherits from PlatformAdapter.

namespace PortableAzure.Phone8.Adapters
{
    public class Platform : PlatformAdapter
    {
        public IIdentity _identity = new Identity();

        public override IIdentity Identity
        {
            get
            {
                return _identity;
            }
        }
    }
}


Next, add the Identity class which is where all of the heavy lifting is done for the login logic.

namespace PortableAzure.Phone8.Adapters
{
    public class Identity : IIdentity
    {
        public async void Authenticate()
        {
            var app = ((App)Application.Current);

            string message = string.Empty;

            while (this.User == null)
            {
                try
                {
                    User = await app.Azure.MobileService.LoginAsync(MobileServiceAuthenticationProvider.Twitter);

                    message = string.Format("You are now logged in - {0}", User.UserId);
                }

                catch (InvalidOperationException)
                {
                    message = "You must log in. Login Required";
                }
            }

            MessageBox.Show(message);
        }

        public MobileServiceUser User { get; set; }
    }
}   
   
   
   
Now that the Windows Phone implementation is complete we need to tell the Service library what is the current class is for the PlaformAdapater.  This is set in the App.xaml.cs class in the App contstructor:

public App()
{
   Azure = new AzureMobileServices();

   PortableAzure.Core.Services.PlatformAdapter.Current = new Platform();

   ...

Windows 8

To implement the PlatformAdapter class in the Windows 8 application, you could follow the same steps as documented for the Phone project, but that is duplication and not manageable over time.

So in this case we will use add the existing Identity and Platform classes then add conditional compile statements to the areas of the classes where needed to address the small differences for Windows versus Phone.

Add Existing item by holding the Alt key and dragging the file, or the whole folder from the Phone project to the Windows 8 Project.  Thanks Matt Hidinger for this little trick. You could also just go through the right click -> add existing -> add as link process but now that you know the "Hold Alt + Drag" why??

Here are the completed Platform and Identity classes.  You will need to repeat the setting of the current platform in the App.xaml.cs constructor.

Platform.cs


#if NETFX_CORE

namespace PortableAzure.Win8.Adapters

#endif



#if WINDOWS_PHONE

namespace PortableAzure.Phone8.Adapters

#endif

{
    public class Platform : PlatformAdapter
    {
        public IIdentity _identity = new Identity();

        public override IIdentity Identity
        {
            get
            {
                return _identity;
            }
        }
    }
}

Identity.cs

#if NETFX_CORE

namespace PortableAzure.Win8.Adapters

#endif


#if WINDOWS_PHONE

namespace PortableAzure.Phone8.Adapters

#endif

{
    public class Identity : IIdentity
    {
        public async void Authenticate()
        {

#if WINDOWS_PHONE

            var app = ((App)Application.Current);

#endif


#if NETFX_CORE

            var app = ((PortableAzure.Win8.App)(Windows.UI.Xaml.Application.Current));

#endif

            string message = string.Empty;

            while (this.User == null)
            {
                try
                {
                    User = await app.Azure.MobileService.LoginAsync(MobileServiceAuthenticationProvider.Twitter);

                    message = string.Format("You are now logged in - {0}", User.UserId);

                }

                catch (InvalidOperationException)
                {
                    message = "You must log in. Login Required";
                }
            }

#if WINDOWS_PHONE

            MessageBox.Show(message);

#endif

#if NETFX_CORE

            var messageDialog = new Windows.UI.Popups.MessageDialog(message);

            await messageDialog.ShowAsync();

#endif

        }

        public MobileServiceUser User { get; set; }

    }

}

Note, be sure to use the full namespace OR add more #if at the top for the imports.

Cleanup & Consolidation

Now that there is a single place where the application executes the call to Authenticate, through the magic of #if and reusing existing files, time to delete some code.  Nice right?

In Part, each of the front end projects had code in the MainPage.xaml.cs file within the "Loaded" handler to execute the Azure authentication code.  That can be replaced by using the Event Messaging Bus provided by MVVM Light and sending the LoginMessage.

Messenger.Default.Send<LoginMessage>(new LoginMessage());

In the MainViewModel, add the handler in the constructor and the Login subroutine to call the Authenticate method in the Identity interface.

 public MainViewModel()
 {
     Messenger.Default.Register<LoginMessage>(this, m => { Login(); });
  }

 public void Login()
 {
     if (PlatformAdapter.Current.Identity.User == null)
     {
         try
         {
           PlatformAdapter.Current.Identity.Authenticate();
         }
          catch (Exception ex)
         {
             Debug.WriteLine(ex.ToString());
         }
     }
 }

Now when either platform is run, the Login entry point happens in the MainViewModel upon loading of the main page.  Another option, if you wanted to eliminate the messaging, would be to add a login button and have the ICommand call the Login method thus eliminating any code behind in the MainPage.xaml but that depends on your applications needs.

Windows Phone
Windows 8 / RT



Wrapping Up Authentication

One item to mention, in this example every time the app is run on either platform the user will have to authenticate.  When the MobileServiceUser is successfully authenticated, there are two properties that you can save; MobileServiceAuthenticationToken and UserId respectively.  In a subsequent execution of the app, create a new instance of the MobileServiceUser and set the CurrentUser property of the AzureMobileService.MobileService. For Example:

var user = new MobileServiceUser(mySavedUserId);

user.MobileServiceAuthenticationToken = mySavedMobileServiceAuthenticationToken;

App.MobileService.CurrentUser = user;

Part 1 and Part 2 has shown a simple introduction of how to use portable class libraries with Azure Mobile Services and through the use of a little indirection reuse all the code possible BUT also keep the MVVM implementation and code organization as clean as possible.

Final Code for Part 2 located here

Read more →
Powered by Blogger.
 
Creative Commons License
TattooCoder.com by Shayne Boyer is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.