October 31, 2014 4:45 GMT

iBeacons Everywhere

iBeacons were everywhere at Xamarin Evolve this year. From the Evolve Quest app, to the Darwin Lounge, to the presentation I gave with James, attendees got to experience using iBeacons as end users, learn about them in a lecture setting, and do hands on coding with them on both iOS and Android.

iBeacons at Evolve

Among the fun activities for people to do at Xamarin Evolve were the mini-hacks in the Darwin Lounge. Included in these was an Estimote iBeacon mini-hack that allowed attendees to create a simple app to experience iBeacons for themselves. The iBeacon mini-hack is available in the mini-hack repo on GitHub so you can try it yourself.

mini-hacks

The iBeacon mini-hack consists of a simple example that uses either Core Location on iOS to detect the proximity of an Estimote beacon, or the Estimote SDK Xamarin component on Android.

The code is different on each platform since these are different APIs, however conceptually it is very similar. For example, both platforms implement the concept of ranging, where the app will discover the proximity to a beacon.

On iOS, the CLLocationManager implements this in the DidRangeBeacons event:

// iOS uses CLLocationManager.DidRangeBeacons
locationManager.DidRangeBeacons += (object sender,
  CLRegionBeaconsRangedEventArgs e) => { ... }

whereas on Android it goes through the BeaconManager‘s Ranging event:

// Android uses BeaconManager.Ranging
beaconManager.Ranging += (object sender,
  BeaconManager.RangingEventArgs e) => { ... }

The mini-hack has some other goodness, too. In the iOS case, the walkthrough also shows you how to handle the new authorization and setup requirements for Core Location that were added in iOS 8.

I uploaded my completed solution for the mini-hack here.

Check out the mini-hack and see if you can come up with some novel use-cases for deploying iBeacons.

Happy ranging!

October 31, 2014 4:11 GMT

Some experiences with the new Support packages on NuGet

I spent some time moving over to the new Support packages Xamarin released on NuGet, instead of using the versions from the Component store.

Jonathan Dick made a nice post about what makes the packages on NuGet a bit more smarter than they were previously, which I find very interesting. However, it is not all happy times as there seems to be some caveats by using these packages.

Hence, here are some findings that you might encounter when using them.

I have some Android Library projects, each updated to the new NuGet packages. The Android Library projects seem all to have $(TargetFrameworkVersion) defined in the .csproj file, which comes from the setting in the project properties in the Application tab called Compile using Android version. This sets the $(TargetFrameworkVersion) in the project file. However in my Android Application projects, I previously had that same option set to Use Latest Platform. The problem with this, is that it does not seem to explicitly set that in the csproj file. This gives some problems when fetching the NuGet for the Application project, where NuGet might tell you that it is incompatible and simply not install it (not cool :( ).

Another problem is that, say you have an Android Library project using Google Play services, this is also a NuGet package, which additionally brings in a lot of Support packages (including v4, v7, v13 (whoa!)). Now you do all your stuff with the Play services inside of the library, so you think you can suffice with simply adding the needed Support packages in your Android Application project. Lets say you only need Fragment backwards compatibility and you just pull in Support v4. This will give you a headache and throw a bunch of errors telling you that you have duplicate managed types.
The solution seems to match the packages you added in the Android Library project. So if you are using Google Play services in your Android Library project, you need the exact same packages in your Android Application project.

Apart from these couple of things, it seems that the new packages work pretty well. It also seems that additional Support v7 packages have made it into NuGet and more are to come!

I've switched the MvvmCross "3.5" branch and my own MvxPlugins "threeandahalf" branch to use this new stuff.
October 31, 2014 5:17 GMT

Microsoft Band (day 1)

I had no clue Microsoft was working on the Band until the reviews starting to leak out last night, but I was immediately keen to try one out. Today I dropped by the Microsoft Store at opening to pick one up, and I'm happy to report it's actually a pretty cool piece of tech.

Let me start by saying two things: (1) I really wanted to like the Band ~ smart watches don't really appeal to me but this feels smaller, less obvious and more focused that the Apple and Android devices (2) my primary use-case is running - with GPS and heart rate recording - so that is my measure of the device's success.

TL;DR I like the device a lot, my initial impression is that it does what I want while running and it pleasantly surprised me in a lot of other ways as well.


Features

The initial setup was painless: I downloaded the Microsoft Health app to my iPhone, paired the Band and was immediately able to receive alerts (texts, voicemail alerts, etc) on the Band. The app was easy enough to figure out: I changed the color scheme and turned on Facebook, Twitter, Notifications... and everything just worked.

Using the Band's menu on the phone screen is surprisingly smooth - although I'm not sure how people will bigger hands will find it. The device itself is less bulky than I expected (especially on my small wrist)... don't get me wrong it still feels "big" and looks a little "wide", but it's not heavy and after I'd worn it for a while I barely noticed it.

Playing around with heart-rate monitoring, calendar, notifications, alarms, the step counter, the UV detector and the workouts feature was a lot of fun; but as I said my primary concern was using it for run training...

Running

I was easily able to figure out how to get everything working, but here is the running "support page" for reference. To be clear - you do NOT need your phone with you while running! The GPS functionality is built-in to the Band, along with the step-counter and heart-rate monitor, so you get plenty of good data while exercising without dragging a phone around :)

To compare the accuracy and usability of the Band I wore my Garmin Forerunner 10 for comparison. They both took a while to 'find satellites' (and it always feels like forever when you want to start running), but the Band was actually ready slightly ahead of the Garmin.

During the run, they both kept in pretty close sync, beeping out kilometer markers at roughly the same time (and therefore showing similar splits). There was a bit of drift between them but nothing dramatic. The screen of the Band was constantly lit (which was great, as I was running at night), and the elapsed time is pretty easy to read. The heart-rate text is pretty small to read while you're moving unfortunately.

Your pace is available by 'swiping down' on the screen while you're running. It auto-hides after a while, returning the display to the elapsed time and heart-rate. I haven't got pictures of these screens and haven't found them on the support site yet. At each kilometer marker (or mile if you must) it beeps and shows your pace-per-kilometer/mile for a few seconds, before again reverting to the elapsed time display.

After the run was over, I uploaded my Garmin data to Strava (as I normally do) so I could compare the results. The Band seamlessly sync'd its data to my phone as soon as I opened the Microsoft Health app.

Summary Data

Here's the summary info from the Microsoft Health app versus Strava's view of my Garmin-collected data. Both compare pretty well - the Calories calculations are fairly different (something to investigate further) but the distance and pace are pretty close. The best thing about the Band is the inclusion of heart-rate info, without the hassle of a chest-strap or other additional device.



The Band also has an interesting 'Recovery' estimate (not shown) which I'm still to learn more about.

Map

Here's the two maps (Band/Health app vs Garmin/Strava). The Band does cute color-coding of pace, I'm not sure whether Strava can do that with more information (it does not have any heart rate data available as the Garmin Forerunner 10 does not support that). The Band track seems a little more accurate, but with a sample size of one it's a little early to draw conclusions about that.



I'm not sure what to make of the Band coloring a 4'20" kilometer as "snails pace" (jk :-)

Splits

Both provide similar splits data, although the data varies slightly (due to GPS variance).



Graphs

The Microsoft Health app shows pace, heart-rate and elevation. Strava doesn't get heart-rate data but graphs the other two (note the Garmin's GPS error causing a pace calculation error in the Strava graph around the 2km mark).



Navigating around the map, splits and graphs is fairly easy once you figure it out. Just tap and swipe around until you get the hang of it.

Conclusion

After less than a day it's probably a bit early to draw conclusions, but I overall I had a lot of fun playing with the Band today. Can't wait to race with it and check the data against the watch (and to see heart-rate info for the first time in ages). Here's hoping the number of app integrations increase and they eventually work out sync'ing with Strava!
October 30, 2014 5:36 GMT

Create Your Own Scavenger Hunt with Evolve Quest

Xamarin Evolve 2014 attendees had an action packed five days, with activities ranging from mini-hacks in the Darwin Lounge and a plethora of amazing sessions, to seeing Whale Sharks at the Georgia Aquarium. At the center of Xamarin Evolve lived a brand new interactive scavenger hunt, the Xamarin Evolve Quest. Once the Xamarin Evolve Quest app was installed on their smart phones, questers were on their way to winning an exclusive Xamarin Evolve 2014 monkey. monkey2014

Hidden around Xamarin Evolve 2014 were iBeacons from Estimote that questers needed to find using clues from the Xamarin Evolve Quest app. Finishing the quests involved answering several Xamarin trivia questions and completing tasks, such as trying out Google Cardboard.

Evolve Quest

More that 400 attendees finished the Xamarin Evolve Quest and walked away with a limited-edition Xamarin Evolve 2014 monkey. With the success of the Xamarin Evolve Quest, we wanted to enable any Xamarin developer to get their hands on the source code to create their very own scavenger hunt, so get it from GitHub today!

October 30, 2014 10:02 GMT

Hack Day Sydney – 6/12/14 – call for presentations!

It’s nearly that time again! The 6/12/14 will be the next Xamarin Hack Day in Sydney.

This time we’re going to have two tracks a ‘introductory’ and a ‘advanced’ track. We need presenters for both.

I’ve included a basic layout below:

Introductory:

The introductory will have a similar format to the latest one in Brisbane.

Advanced:

I’m keen to hear about any type of presentation. It could be Xamarin.Forms, Windows Phone, Android/iOS, deployment, CI, F#, C#, ReactiveUI, Mono, IDE etc.

If you want to present twitter me @rid00z or email me here: http://www.michaelridland.com/about/

If you want to attend then signup at the website.

ps, if your in Melbourne there’s a hack day in the weekend before 29/11/14. 

 

The post Hack Day Sydney – 6/12/14 – call for presentations! appeared first on Michael Ridland.

October 29, 2014 11:11 GMT

Particle Designer with CocosSharp

CocosSharp comes with a variety of particle systems. For example, the GoneBananas sample uses the sun particle system (CCParticleSun) to create an animated sun, as well as the explosion particle system (CCParticleExplode) to create an explosion effect whenever the monkey collides with a banana.

GoneBananas

Although they are customizable, sometimes the built-in particle systems aren’t exactly what you want. Game developers often use particle system design tools for creating custom particle systems. One such commercial tool is the excellent Particle Designer from 71Squared.

Using Particle Designer is a great way to create custom effects and I was pleased to discover it works well with CocosSharp. For example, instead of using CCParticleExplode let’s change GoneBananas to instead use particle systems designed in Particle Designer, to create concentric exploding rings, as shown below:

particle designer

Particle Designer has an export feature that supports a variety of export formats. In this case I exported the particle systems as plist files and added them to the respective Content folders of the CocosSharp iOS and Android projects respectively.

Then, to include them in the code, create a CCParticleSystemQuad for each particle system:

var particles = new[] { "innerring.plist", "outerring.plist" };

foreach (string p in particles) {
    var ps = new CCParticleSystemQuad (p);
    ps.Position = pt;
    AddChild (ps);
}

Now when you run the game, the custom particle systems appear as shown below:

rings


October 29, 2014 2:06 GMT

Automate UI Testing Using Xamarin.UITest

Before publishing an app, either to an app store or via enterprise deployment, it’s important to test it for functionality. However, due to today’s device fragmentation, testing an app on every device configuration is nearly impossible. Thanks to automated UI testing, though, developers can write automated UI tests for mobile applications and run those tests to check for expected behavior.

Xamarin.UITest is an automated UI testing framework based on Calabash that allows developers to write and execute tests in C#. Moreover, it uses the popular NUnit testing framework to validate these tests.

Writing tests and executing them from Xamarin Studio is easy and can be done from Visual Studio, as well. To get started, just create a new ‘NUnit Library Project’ in Xamarin Studio.

Xamarin-UITest-Image1

To add test functionality, simply add a ‘Xamarin.UITest’ NuGet Package to this project.

Xamarin-UITest-Image2

Now, using TestFixtures and Test attributes, it becomes easier to write automated UI tests. For example: when a user enters a credit card number less than or greater than the desired number, the test should fail. Otherwise, it should pass given a valid credit card number.

[Test]
public void CreditCardNumber_ToShort_DisplayErrorMessage()
{
  _app.EnterText(EditTextView, new string('9', 15));
  _app.Tap(ValidateButton);
  // Assert
  AppResult[] result = _app.Query(ShortErrorMessage);
  Assert.IsTrue(result.Any(), "The error message is not being displayed.");
}
[Test]
public void CreditCardNumber_TooLong_DisplayErrorMessage()
{
  _app.EnterText(EditTextView, new string('9', 17));
  _app.Tap(ValidateButton);
  // Assert
  AppResult[] result = _app.Query(LongErrorMessage);
  Assert.IsTrue(result.Any(), "The error message is not being displayed.");
}
[Test]
public void CreditCardNumber_CorrectSize_DisplaySuccessScreen()
{
  _app.EnterText(EditTextView, new string('9', 16));
  _app.Tap(ValidateButton);
  _app.WaitForElement(SuccessScreenNavBar, "Valid Credit Card Screen did not appear",
    TimeSpan.FromSeconds(5));
  // Assert - Make sure that the message is on the screen
  AppResult[] results = _app.Query(SuccessMessageLabel);
  Assert.IsTrue(results.Any(), "The success message was not displayed on the screen");
}

Once, these steps are completed, the tests can be executed from ‘Run Unit Tests’ or can be submitted to Xamarin Test Cloud to execute on thousands of different devices.

A step-by-step guide and mini-hack from Evolve 2014 is available here.

For more information about Xamarin.UITest visit: http://developer.xamarin.com/guides/testcloud/uitest/intro-to-uitest/

Enjoy your UI testing!

Discuss this blog post in the Xamarin Forums

October 29, 2014 12:00 GMT

Russ Fustino, Full Time CEO of Fustino Brothers

  • I am back to being CEO of Fustino Brothers, full time. Email russ@fustinobrothers.com and please follow @FustinoBrothers and @RussFustino
  • I am taking a little break  from my contract with Xamarin and Developer Evangelism
  • On a little painful news, it is starting to look like I need laser surgery on my back. During recovery period I plan on doing a lot of coding, as traveling will not be possible, and publish the Jethro Tull iOS and Android Apps using Xamarin. I will know more in a couple of weeks.
  • I am heading up to the Jethro Tull shows in Providence, RI tonight and Lynn, MA on Saturday .  I will be  showing Ian Anderson of Jethro Tull the FBI Jethro Tull app  for Windows Phone and Windows Store right after sound check in Lynn. How exciting is this!
  • The App Studio team will be at the Lynn, MA show to capture the moment.
  • Then its off  to the MVP Summit for my favorite conference of the year! I am so looking forward to seeing everyone! I think I am in trouble however, as my room mate is the one and only Jonas Stawski. Yikes! Smile

blog

  • I will be documenting my way thru this experience of Using App Studio to start an app and using Xamarin to finish it. I am working on a new set of videos for WintellectNOW. More details to come as to topics and content.
  • I am working with the App Studio Windows   team to make the generated C# projects Xamarin friendly, facilitating cross platform capabilities.  The team is very close right now , and keeps getting closer in every release.
  • I hope to be back with Xamarin after the new year in some capacity.
  • I received my Xamarin Mobile App Certification in October and my 2014 Renewal for Microsoft MVP 2014 in Microsoft Platform Development!
  • Wish me luck!

Xamarin Ceritified Mobile Developer Badge-small res

MVP_BlueOnly

October 28, 2014 8:00 GMT

Join Us for a Xamarin Fall European Roadshow

Earlier this year, we embarked on a Xamarin European Road Show where we talked to thousands of developers about creating beautiful, native mobile apps in C# with Visual Studio and Xamarin.

Xamarin Evangelist James Montemagno with attendees at the Xamarin Summer 2014 European Roadshow

Due to popular demand, we are doing it again! During the month of November, we will be in Europe with stops in The Netherlands, France, Denmark, UK, Germany, Italy, and Sweden. Join us to explore the latest Xamarin Platform Previews, Xamarin Test Cloud, and Xamarin Insights.

Don’t miss the opportunity to meet the Xamarin team, connect with other developers, show off your apps, and talk all things mobile. Register now for an event near you today:

We look forward to seeing you in Europe!

October 27, 2014 6:42 GMT

Air New Zealand: getting mobile right

The Air New Zealand app has come a long way - they used to just have a sticker with an RFID chip on the back, and now they have moved all of that to iOS and Android apps, with (shock horror) QR codes for your boarding pass.

Despite the unversal WTF around QR codes, it works great. Having the same info in a Passbook pass would solve the unlock-and-use problem, but thats a fairly minor niggle. Mostly, it's focused - no ads, no upsell, nothing which really gets in the way.

Some of the things they let me do in the app (and it IS an app, not a mobile website in a box like most other airline apps):

  • Check in, and pick my seat (ok, the last bit there is a website, but it's pretty seamless)
  • See all my flights
  • See my airpoints info, my status level, how many points I got for the last flight, how many upgrades I have etc.
  • It shows up on the homescreen when I'm near one of the major airports - I assume this is using GeoJSON

Their newest feature, however, is for something else I love: coffee. When you check in to the lounge (which requires you to open the app and scan your boarding pass) it asks you if you want a coffee

If you say yes, it shows a list of your previous orders, and how long it will take before your coffee is ready:

Once it's ready, you get a push message to tell you:

It's a fairly simple thing, but it removes the queue from the coffee bar, and it's a nice surprise. I thought they used iBeacons for detection, but I think it's just triggered from the check in. Either way, I'd like the pop up to show when I walk into the airport - then if there is a 20 min delay (which is common for coffee), I can order it while I'm still in the security queue.

Well done, Air NZ. Awesome use of mobile tech.

October 27, 2014 4:00 GMT

Episode 19: Exploring Runscope with John Sheehan

APIs have historically been difficult to debug and monitor, and Runscope was founded to help solve this problem. Join us as we talk to John Sheehan about what Runscope offers, and how developers can leverage it to make API development more enjoyable.

Hosts: Greg Shackles, Jon Dick

Guests: John Sheehan

Links:

Thanks to our Sponsors!

Raygun.io

Raygun.io – Exceptional Error Tracking Raygun.io is the fastest and easiest way to track your application’s errors and get the level of detail you need to fix crashes quickly. Notifications are delivered right to your inbox and presented on a beautiful dashboard.

October 27, 2014 11:03 GMT

Should I use Xamarin for Mobile Development? YES you should!

Should I use Xamarin for Mobile Development?  - This a very important question and a question that can cost you alot of time and money if you get it wrong. After wasting many months of my time playing with open web platforms I eventually found Xamarin and since then I’ve not found anything that compares.

So that answer is YES! In my opinion Xamarin is hands down one of the best mobile development platforms available in the market today. Many people don’t know what they’re missing out on by not using Xamarin so I’m going to highlight some reasons I think people should be using Xamarin.

1) It’s Native but with 80%+ code share?

So for those that aren’t aware of Xamarin or how it works, Xamarin allows you to develop apps for iOS, Android and Mac from a single code base. When I say this I don’t mean in a webview or customised API, it actually uses the Native APIs. So for example when developing on Xamarin.iOS you’ll be using UIKit which is the same API that a native developer would be using.

2) C# and F# are Modern languages

C# might not be the hipster language of the year but it is a continually evolving language with solid features like type inference, dynamic types,  language integrated query (LINQ), async/await and first class functions. C# is designed for developing large robust applications. And for the functional types there’s F#.

Both languages have been aggressively developed for many years and it’s not slowing down, C# 6 and F# 4 are soon to be released. If you’ve seen C# a few years ago I encourage you to give it another go as it’s evolved in leaps and bounds.

3) async/await

.. ‘wait but javascript is all async’ i hear you say…  C#/F# async/await is different to what people normally think async is. C#/F# async/await tackles the callback hell problems in rich clients, anyone who works with rich clients will know of these problems. This is a problem that’s attempted to be solved with promises and generators but neither are at the level of async/await.

Here’s a little before/after sample:

Before:

doAsync1(function () {

doAsync2(function () {

doAsync3(function () {

doAsync4(function () {

      })
     })
   })
})
After:

await doAsync1()
await doAsync2()
await doAsync3()
await doAsync4()

4) Watches, Google Glass wearables and the future of devices.

In case you haven’t noticed the future isn’t just mobiles it’s wearables, devices and IOT. Xamarin has same day support for all these platforms including android wear, google glass, Amazon TV and more. As I’ve said before Xamarin uses the Native APIs and compiles down to native so using Xamarin you’re in the perfect position develop all modern platforms.

5) It’s ready now!

All the time I hear people say ‘html is a fast moving target’ or ‘it will get there eventually’. Xamarin is here now, it’s Native and it’s cross platform. Why wait to have a great app when you can have it now and as a bonus know that your application is future proof for future devices.

6) It’s fast and stable

From personal experience the Xamarin traditional (Xamarin.iOS and Xamarin.Android) platform is solid, fast and stable. You’d be hard pressed to find a problem with the core parts of the platform, any app bugs will likely be your own bugs.

7) Documentation

The documentation for Xamarin is solid and there’s 100s of sample app on github. Provided by Xamarin and others in the community.

8) Xamarin.Forms

So how about 100% codeshare and still be Native? Xamarin.Forms allows you to program against a single API and have that single API mapped to native controls on each platform. Hanselman describes it well, ‘Write Once Run Everywhere AND Be Native’.

It’s still early days for the product but the top component developers like Telerik and DevExpress are already developing components for Xamarin.Forms.

9) It’s the best of all worlds (Hybrid and Native)

If you’ve taken a look at my Xamarin mashup blog you’d already know that the possibilities with Xamarin are vast, you can essentially create your own Cordova and you can completely integrate it with your C# Mvvm/c# Native Code. So you have the full power of the .net framework to build your client application architecture which becomes very useful when you have complex requirements like Offline.

10) Large Community

Xamarin uses the .net framework and because of this it’s inherited the pre-existing community, this means that even though it’s a fairly new platform we already have support for Awesome projects like Json.net, Fody and ReactiveExtensions/ReactiveUI.

11) Profitable Innovative Company

Xamarin as a company has a passion for enabling mobile developers to deliver leading experiences. Their products cost money Yes.. but it’s good for us as customers. I see many people complain about the pricing but Xamarin charging money for products allows them to put money back into building amazing products for us. This year at Evolve Xamarin released some great new products including Insights – Analytics Cloud Service, a faster Android emulator, Test Cloud and a performance profiler. In the future Xamarin is on the rise and this means our tools are only going to get better and better.

This is why I choose Xamarin and I think you should too….

If you have any questions regarding Xamarin or need any help please contact me I’m always happy to help.

Thanks

Michael

The post Should I use Xamarin for Mobile Development? YES you should! appeared first on Michael Ridland.

October 27, 2014 8:00 GMT

Join Xamarin at TechEd Europe 2014

The Xamarin team is excited to once again be attending TechEd Europe, this year in Barcelona, Spain.

TechEd Europe 2014 Logo

You can find us at the Xamarin booth (#31) throughout the conference from October 28th – October 31st. We welcome you to stop by with your technical questions and to learn more about the awesome announcements made at Xamarin Evolve 2014, including Xamarin Platform Previews, Xamarin Insights, and updates to Xamarin Test Cloud.

In addition to chatting with us at the booth, we also invite you to check out James Montemagno’s talks on Wednesday, Thursday, and Friday:

  • Wednesday, October 29th, 12-1:15 pmDEV-B217 Go Mobile with C#, Visual Studio, and Xamarin: Learn how to leverage your existing Microsoft .NET and C# skills to create iOS and Android mobile apps in Visual Studio with Xamarin. You’ll get the tools to see how much existing C# code can go mobile to iOS and Android, plus determine the architecture necessary to support maximum code sharing and reuse, as well as guidance and best practices for handling fragmentation across and within each device platform.
  • Thursday, October 30th, 6:30-8:00 pmAsk the Experts Session, Table 43 Mobile App Development: James and Principal Program Manager Lead Ryan Salva from Microsoft will be available to answer your questions during this Ask the Experts Session on Thursday.
  • Friday, October 31st, 10:15-11:30 amDEV-B306 Building Multi-Device Applications with Xamarin and Cordova with Office 365 APIs: Ryan Short, Technical Evangelist at Microsoft, will join James during this session on how to use the Microsoft Office 365 APIs in your mobile apps. During the session, you’ll see sample apps running, understand the scenarios where you would use Office 365 APIs in mobile device applications, and learn how to get started with the Office 365 APIs.

We look forward to seeing you in Barcelona!

Can’t make it to TechEd Europe 2014? We’ve got you covered with a Xamarin Fall European Roadshow starting in November. Look for details on the blog tomorrow to register and join us!

October 27, 2014 1:37 GMT

Xamarin Tools: Components, Components, Components!

The Xamarin tool ecosystem is gaining popularity, as more developers continue to build tools with mobility in mind. Here's how to use them in your projects. 

I couldn't help but think about Steve Ballmer's "Developers, developers, developers! …" chant. While often lampooned, the chant shows how important developers are to growing the Microsoft platform.

End-user developers and companies will often judge a company's acceptance in the marketplace by the number of third-party components and add-ins that are developed around that product. It's a complaint I've heard leveled against Xamarin, that it lacks a robust ecosystem of tools, but that is changing.

Url: http://visualstudiomagazine.com/articles/2014/10/01/xamarin-tools.aspx

October 26, 2014 12:00 GMT

Xamarin Components and NuGet

Xamarin Studio 5.5 and Xamarin for Visual Studio 3.7 have support for Xamarin Components with NuGet package dependencies. So you can now have Xamarin Studio or Visual Studio add NuGet packages to a project when a Component is installed from Xamarin’s Component Store.

The NuGet Support in Xamarin Studio 5.5 post looked at installing a Component with a NuGet package dependency into a project but did not cover how to create one of these Components. So let us take a look at how to modify an existing Component so it has NuGet package dependencies.

Adding a NuGet Package Dependency to a Component

In this section we will look at modifying a Component so when it is installed it adds NuGet packages to the project as well as referencing the assemblies that are included in the Component.

First download the latest version of the xamarin-component command line application which has been updated to support Component’s with NuGet packages dependencies.

The downloaded xpkg file is a zip file containing xamarin-component.exe. So rename the file to have a .zip file extension and then extract the executable.

Now let us see how to add a single NuGet package dependency to the Component. If you are using a component.yaml file to generate your Component you can add the NuGet package dependency by adding the following to your component.yaml:

packages:
  "": Newtonsoft.Json, Version=5.0.8

With the above defined in your component.yaml file you can run the xamarin-component.exe package command to generate your Component’s .xam file.

Windows:

xamarin-component.exe package path\to\directory-with-component-yaml

Mac:

mono xamarin-component.exe package path/to/directory-with-component-yaml

If you then look inside your generated Component file (.xam), which you can do by renaming its file extension to .zip, you will see the package defined in the component/Manifest.xml file:

<packages>
  <package id="Newtonsoft.Json" version="5.0.8" />
</packages>

If you are using the xamarin-component.exe create-manually command line you can add the same NuGet package dependency by adding the following command line argument:

--package="":"Newtonsoft.Json, Version=5.0.8"

This packaged Component will install the Newtonsoft.Json NuGet package into any Android, iOS or Windows Phone project. If you need to install a particular NuGet package for a particular project type you can specify the target project type for the NuGet package dependency. Shown below is a more complicated example from a component.yaml file where NUnit and Newtonsoft.Json are configured so they will only be installed into Android projects, whilst log4net is only installed into iOS projects, and finally Ninject will be installed into all project types.

packages:
  android:
    - NUnit, Version=2.6.2
    - Newtonsoft.Json, Version=5.0.8
  mobile: Ninject, Version=3.2.0
  ios: log4net, Version=2.0.0

Note that mobile used here is equivalent to the empty double quoted string “” which was used in the previous example with the single NuGet package.

If you then generate the Component again using the xamarin-component.exe package command you will see the Component’s manifest file now contains the following:

  <packages>
    <package id="NUnit" version="2.6.2" framework="android" />
    <package id="Newtonsoft.Json" version="5.0.8" framework="android" />
    <package id="log4net" version="2.0.0" framework="ios" />
    <package id="Ninject" version="3.2.0" framework="mobile" />
  </packages>

If you are using the xamarin-component.exe create-manually command line you can add the same NuGet package dependencies to your Component by adding the following command line arguments:

--package="android":"NUnit, Version=2.6.2"
--package="android":"Newtonsoft.Json, Version=5.0.8"
--package="mobile":"Ninject, Version=3.2.0"
--package="ios":"log4net, Version=2.0.0"

With the NuGet package dependencies defined as shown in the previous examples when you install the Component into a project the NuGet package will be installed and a reference will be added to the assemblies in the lib directory of the Component. If you want to only add the NuGet package to the project and not the assemblies in the lib directory then you can create a Shell Component which we will look at in the following section.

Creating a Shell Component

A Shell Component is special type Component that is basically a wrapper around one or more NuGet packages. It will only install the NuGet package into the project and not add references to any assemblies in the Component’s lib directory.

To configure a component to be a Shell Component you can add the following to your component.yaml file:

is_shell: true

When you generate your Component’s .xam file you will see that the Component’s Manifest.xml file now contains the is-shell attribute in the component element:

<component format="1" id="mycomponent" is-shell="true">

If you are using the xamarin-component.exe create-manually command line argument you can do the same thing by passing the following argument:

--is-shell

Backwards compatibility is something to consider if you decide to create a Shell Component. If you need a Shell Component to work with older versions of Xamarin Studio and Xamarin for Visual Studio that do not support Component’s with NuGet package dependencies then you should also include the assemblies in the lib directory of the Component. The Android Support Library v13 Component is one example that has a NuGet package dependency and also includes an assembly in its lib/android directory. When installing the Android Support Library v13 Component into an older version of Xamarin Studio the NuGet package will not be installed and instead the assembly will be referenced from the Component’s lib/android directory. If the Android Support Library v13 Component is installed with Xamarin Studio 5.5 or above then the NuGet package will be installed but the assembly from the lib/android directory will not be referenced.

NuGet Package Sources

The NuGet package dependencies that a Component has must be available from the official NuGet Gallery before your Component is submitted to the Component Store.

If you are testing a NuGet package that is not currently available from the official NuGet Gallery then you can copy it into the local machine’s NuGet cache directory. Xamarin Studio and Xamarin for Visual Studio should find the NuGet package in the local NuGet cache instead of trying to download it from the NuGet Gallery.

Creating a Component

There are some example Component’s that have NuGet package dependencies available on my GitHub page. The Awesome Component example is a Shell Component that uses a rakefile and the xamarin-component create-manually command line to generate the Component. The My Component example is another Shell Component that uses a component.yaml file that defines NuGet package dependencies.

For more detailed information on how to create a Component please see the Submitting Components page.

October 26, 2014 4:41 GMT

Retailers blocking Apple Pay. This will not end well.

From The Verge and Macrumours:

In fact, a significant number of merchants, including heavyweights like Walmart, Kmart, 7-Eleven, and Best Buy, are in outright competition with Apple Pay. The retailers, through a joint venture formed in 2012, are building their own mobile payment app, called CurrentC. It's expected to launch next year. In the meantime, these retailers have no intention to support Apple Pay.

Except, they are not in competition. Apple Pay can be used at any EMV-based NFC termainal, world wide. CurrentC: not so much. It's US residents only, and even then, only ones who install their app, and set it up. They still need to provide normal credit card processing at tills for the 99% of people who don't, or can't be bothered.

Earlier this week, a leaked internal memo from Rite Aid revealed that the drug store chain was modifying or disabling its NFC readers, preventing access to Apple Pay (and other systems, like Google Wallet and wireless carrier-backed SoftCard, which also depend on the contact-less technology). A representative later confirmed the news to iMore. Today, CVS followed suit and shut out Apple Pay, according to reports. Both will support CurrentC on launch next year

Here's how this is going to go: Apple will own iPhone-based payments, as they are supporting the "open" standard (EMV). Banks and similar places will own the Android-based market with their own wallets. All of them are the same tho - EMV-based NFC. For those without either (or a willingness to use them), the banks will do EMV based credit cards, or stickers which stick on your phone (popular in the UK).

The US will continue to flounder with stupid, old, insecure payment methods for a few years, and then all the crazy shit like signing something which looks kind of like your name, or CurrentC, will die and they'll finally get onboard with NFC.

Or the banks and credit card companies will pull finger and require that Rite Aid et all take 100% liability if they don't support EMV at the point of sale (like most of the rest of the world). That might change it up a bit quicker.

Stupid, and short sighted. Which is about normal.

October 24, 2014 2:22 GMT

Xamarin Evolve 2014 Xammy Award Winners

This year we hosted the inaugural Xammy Awards, recognizing top apps on the global stage of Xamarin Evolve. The competition was fierce, with 11 amazing apps in 4 categories. After much deliberation, our panel of judges selected a winner from each category and our worldwide community voted on a “Developers’ Choice” winner, who were announced on stage at Xamarin Evolve 2014.

Xamarin SVP of Sales and Customer Success, Stephanie Schatz, on stage at Xamarin Evolve 2014 to present the Xammy Awards.

This year’s winners were:

We’d like to congratulate our winners, as well as the other outstanding nominees, once again for the impressive apps that they have built. We invite you to view the videos of this year’s winners and nominees for a closer look at some of the incredible apps being built with Xamarin.

October 24, 2014 1:52 GMT

Some Things in iOS 8

iOS 8 added a lot of new functionality and APIs. Along the way, several things have changed. Here are a few items I’ve come across:

Documents and Library

UPDATE: Xamarin.iOS now handles getting the folder path correctly when using Environment.SpecialFolder in iOS 8 as well.

Prior to iOS8 it was common for Xamarin.iOS applications to access folder paths using the .NET System.Environment class, which on iOS provided a familiar abstraction around native system folders. For example, you could get to the documents folder like this:

var docs = Environment.GetFolderPath (
  Environment.SpecialFolder.MyDocuments);

However, in iOS 8 the location of some folders, namely the Documents and Library folders, has changed such that they are no longer within the app’s bundle.

Apple describes the changes in Technical Note TN2406.

The proper way of determining the location of these folders is to use the NSFileManager. For example, get the location of the Documents folder as follows:

var docs = NSFileManager.DefaultManager.GetUrls (
  NSSearchPathDirectory.DocumentDirectory, 
  NSSearchPathDomain.User) [0];

Location Manager

To use location in iOS you go through the CLLocationManager class. Before iOS 8 the first time an app attempted to start location services the user was presented with a dialog asking to turn location services on. You could set a purpose string directly on the location manager to tell the user why you need location in this dialog.

In iOS 8 you now have to call either RequestWhenInUseAuthorization or RequestAlwaysAuthorization on the location manager. Additionally you need to add either the concisely named NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription to your Info.plist. Thanks to my buddy James for tracking these down.

AVSpeechSynthesizer


The AVSpeechSynthesizer was added in iOS 7, allowing apps to deliver text to speech functionality with just a few lines of code, like this:

var speechSynthesizer = new AVSpeechSynthesizer ();

var speechUtterance = new AVSpeechUtterance (text) {

  Rate = AVSpeechUtterance.MaximumSpeechRate/4,

  Voice = AVSpeechSynthesisVoice.FromLanguage ("en-US"),

  Volume = 1.0f

};


speechSynthesizer.SpeakUtterance (speechUtterance);

The above code worked on either the simulator or a device prior to iOS 8. However, when run on an iOS 8 simulator, you are now greeted with the following error message:

Speech initialization error: 2147483665

However it does appear to work on a device. There is an open bug here: http://openradar.appspot.com/17299966

Thanks to René Ruppert for discovering this. Incidentally, René has a blog post on a few other iOS 8 issues worth checking out: http://krumelur.me/2014/09/23/my-ios8-adventure-as-a-xamarin-developer/

Input Accessory Views

Before iOS 8 you could set the InputAccessoryView on a UITextField from a view contained in another controller.

aTextField.InputAccessoryView = aViewController.SomeView;

While this worked before iOS 8, it did not guarantee the view controller hierarchy would be set up properly. A better approach, even before iOS 8, would be to set the InputAccessoryView directly to an instance of UIView subclass, not one contained in another UIViewController. Practically speaking, people would take the view controller approach because it let them set things up via a xib. Therefore, to handle the view controller case, iOS 8 introduced the InputAccessoryViewController property on UIResponder. It’s still easier to just use a UIView subclass imho, but if you need to use a UIViewController, set it to InputAccessoryViewController.

Action Sheets

Apple states in their documentation that you should not add a view to a UIActionSheet’s view hierarchy. Before iOS 8 adding subviews to a UIActionSheet would actually work, although it was never the intention (nor should it be subclassed). Code that took this approach should have presented a view controller.

In iOS 8 subclassing UIActionSheet or adding subviews to it will no longer work. Additionally UIActionSheet itself has been deprecated. Instead, you should use a UIAlertController in iOS 8 (UIAlertController should also be used in iOS 8 in place of the deprecated UIAlertView) as I discussed in my iOS 8 webinar.


October 23, 2014 8:04 GMT

Debug with the Xamarin Android Player from Visual Studio in VMWare or Parallels

I simply love using my Mac when combined with VMWare for development. I consider it the ultimate setup for mobile development with Visual Studio. Since everything is on the same machine the iOS simulator and Build Host just work. For Windows Phone nested virtualization with Hyper-V seems to just work (as long as you you follow the special setup guide from Nokia).

However, my favorite platform, Android, seems to have fallen by the wayside. If you are inside of VMWare or Parallels it might seem like all hope is lost. You are either stuck with an ARM emulator, always needing to plug in a device, or attempting to do some crazy ssh tunnel to your Mac and maybe get things connected to an x86 emulator running on the Mac. Recently we the brand new Xamarin Android Player, which is a blazing fast emulator that run on Mac or PC.

Now, you will still have an issue that you can’t actually run it in nested virtualization inside of VMWare, so don’t do that. If you have the Android Player installed on your Mac it is easier than ever to get it connected and working with Visual Studio inside of VMWare for a delightful experience. Just follow these simple steps:

1.) Download my MonoDroid Toolkit APK from Github (direct link).
2.) Drag and drop this onto your Xamarin Android Player
3.) Launch app and click Networks Utils
4.) You will see a series of IP addresses listed. We will want to find the last one in the list.

*Notice mine wraps around and is actually 10.71.34.101
5.) Go to Visual Studio and launch the Android ADB command prompt from the toolbar.
6.) Type in “adb connect ipaddressfromapp”
7.) Boom! You are all done! verify with “adb devices” and you should see the device listed.


If for some reason you don’t see it in Visual Studio simply reboot. Here is a video walkthrough.

Can’t connect? Ensure your VM is on a Shared Connection to your Mac:

Need more help, leave comments below or join in on the conversation on the Xamarin Forums.
October 21, 2014 5:30 GMT

Xamarin Evolve 2014 Session Recordings Now Available

At Xamarin Evolve 2014, we were excited to be joined by industry experts and Xamarin engineers delivering sessions on diverse mobile developer topics ranging from the latest in native mobile technologies, to enterprise development, to gaming and more. We are now pleased to make these great Xamarin Evolve 2014 conference sessions available on evolve.xamarin.com for your viewing pleasure.

Xamarin CTO Miguel de Icaza gives a session at Xamarin Evolve 2014

Head over to the Xamarin Evolve 2014 site now to kick back and enjoy the topics you find most interesting. With so many sessions, there’s plenty to choose from and something for everybody.

Enjoy!

October 21, 2014 3:22 GMT

App Spotlight: OBD Fusion Car Diagnostics Video

Evolve 2014 was an eye-opening event. It was an amazing opportunity to see some of the innovative mobile apps people are creating with the Xamarin platform. We’ll be featuring several of these over the coming weeks. Today we’re highlighting an automotive diagnostic app called OBD Fusion.

Matt O’Connor from OCTech, and creator of OBD Fusion, shared his app that wirelessly reads onboard vehicle diagnostics from a car. The app enables car enthusiasts to create their own dashboards and access much of the same diagnostic information a master mechanic would use with specialized automotive equipment to diagnose and tune an automobile. With OBD Fusion, users can calculate fuel economy, graph data, and also test emissions in real-time.

To really appreciate how this works, we got a car and took a drive around Atlanta. Watch it in full-screen to see it in action.

What really impresses me is how polished OBD Fusion is and how cleanly it presents useful information to the user. With sensor data coming in at up to 100 times a second, the app works flawlessly, utilizing multi-threading to process a large amount of data and update the dashboards and graphs in real-time – something only a native app can effectively do.

Matt originally created his app in C# as a desktop application. Utilizing Xamarin, he was able to convert it to iOS and Android with over 90% code-reuse, and by using app templates he’s created native smartphone and tablet user experiences. In addition to the automobile’s sensor data, he’s also integrated sensors on the mobile device, including the GPS and accelerometer to measure position and vehicle acceleration.

Congratulations to Matt for creating an outstanding app!

Learn More

OBD Fusion is available in the iTunes and Google Play app stores.

To get started developing with the Xamarin platform, check out our developer documentation, or get live online training with Xamarin University.

October 20, 2014 1:30 GMT

Xamarin.Forms Book Preview Edition Available Now

The Petzold engine has been churning through the Xamarin.Forms API, and we’re pleased to announce that the first preview edition of Creating Mobile Apps with Xamarin.Forms is now available. It was distributed in print to all Xamarin Evolve 2014 attendees last week and is now available as a free download in a number of formats:

Creating-Mobile-Apps-with-Xamarin-Forms

The six chapters available in the preview edition cover the history of Xamarin.Forms, solution structure, the basics of the view system and building your first Xamarin.Forms app. The extensive samples are also available for download from GitHub.

Charles also presented two talks at Evolve: XAML for Xamarin.Forms and Xamarin.Forms is Cooler Than You Think, both of which will be available shortly as videos of the sessions are published at evolve.xamarin.com.

Evolve-Xamarin-Forms-talk

Work continues on both Xamarin.Forms and the book!

October 19, 2014 1:00 GMT

NuGet Support in Xamarin Studio 5.5

New Features

  • Package version constraints in packages.config files are now supported
  • Xamarin Components can now have NuGet package dependencies

More information on all the new features and changes in Xamarin Studio 5.5 can be found in the release notes.

NuGet Package Version Constraints

NuGet allows you to define a range of package versions that are allowed in your project using the allowedVersions attribute in the packages.config file.

<packages>
  <package id="Newtonsoft.Json" version="5.0.1" allowedVersions="[5.0,6.0)" targetFramework="MonoAndroid44" />
</packages>

In the above packages.config file the project has Json.NET 5.0.1 installed and will only allow updates to versions of Json.NET that are below 6.0.

When you open the solution in Xamarin Studio, and check for updates is enabled in preferences, you will see updates in the Solution window that are valid given the constraint defined in the packages.config file. In the screenshot below an update is shown for Json.NET 5.0.8 in the Solution window even though Json.NET currently has version 6.0.5 available.

Json.NET 5.0.8 package update available shown in Solution window

When you update the NuGet packages from the Solution window Xamarin Studio will now update to a NuGet package that meets the version constraints defined in the packages.config. In the Package Console screenshot below the Json.NET package was updated, with the constraint in place, and Json.NET 5.0.8 was installed.

Json.NET package updated to 5.0.8 - Package Console output

Note that if you install a NuGet package from the Add Packages dialog you can override the constraint and install a NuGet package with a version outside of the range of the constraint.

Components with NuGet Packages

A Component from Xamarin’s Component Store can now declare a dependency on one or more NuGet packages which will be installed into the project when the Component is installed. The Android Support Library v13 Component is one example that has a NuGet package dependency.

Android Support Library v13 Component in Component Store

When you install this Component you will see that it installs the Xamarin.Android.Support.v13 NuGet package.

Android Support Library v13 Component in Solution window

In older versions of Xamarin Studio the NuGet package will not be installed and instead the project will reference the Xamarin.Android.Support.v13.dll which is included with the Component.

The NuGet packages a Component depends on are displayed in the Packages tab on the Component Details page, which you can open by double clicking the Component in the Solution window, or by right clicking the Component and selecting Details.

Android Support Library v13 Packages in Component Details page

From the Packages tab you can also install a NuGet package that a Component depends on if it was removed from the project. So if the Xamarin.Android.Support.v13 NuGet package is removed from the project the Component will be highlighted in red to indicate that there is a problem.

Android Support Library v13 Component error in Solution window

If you then open the Component Details page you will see in the Packages tab that the NuGet package is missing.

Android Support Library v13 CComponent Details page with missing NuGet Package

To add the NuGet package back to the project you can hover the mouse over the warning icon and click the Add Package button that appears in the pop-up window.

Android Support Library v13 CComponent Details page with Add Package pop-up window

October 16, 2014 6:32 GMT

The Wait Is Over: MimeKit and MailKit Reach 1.0

After about a year in the making for MimeKit and nearly 8 months for MailKit, they've finally reached 1.0 status.

I started really working on MimeKit about a year ago wanting to give the .NET community a top-notch MIME parser that could handle anything the real world could throw at it. I wanted it to run on any platform that can run .NET (including mobile) and do it with remarkable speed and grace. I wanted to make it such that re-serializing the message would be a byte-for-byte copy of the original so that no data would ever be lost. This was also very important for my last goal, which was to support S/MIME and PGP out of the box.

All of these goals for MimeKit have been reached (partly thanks to the BouncyCastle project for the crypto support).

At the start of December last year, I began working on MailKit to aid in the adoption of MimeKit. It became clear that without a way to inter-operate with the various types of mail servers, .NET developers would be unlikely to adopt it.

I started off implementing an SmtpClient with support for SASL authentication, STARTTLS, and PIPELINING support.

Soon after, I began working on a Pop3Client that was designed such that I could use MimeKit to parse messages on the fly, directly from the socket, without needing to read the message data line-by-line looking for a ".\r\n" sequence, concatenating the lines into a massive memory buffer before I could start to parse the message. This fact, combined with the fact that MimeKit's message parser is orders of magnitude faster than any other .NET parser I could find, makes MailKit the fastest POP3 library the world has ever seen.

After a month or so of avoiding the inevitable, I finally began working on an ImapClient which took me roughly two weeks to produce the initial prototype (compared to a single weekend for each of the other protocols). After many months of implementing dozens of the more widely used IMAP4 extensions (including the GMail extensions) and tweaking the APIs (along with bug fixing) thanks to feedback from some of the early adopters, I believe that it is finally complete enough to call 1.0.

In July, at the request of someone involved with a number of the IETF email-related specifications, I also implemented support for the new Internationalized Email standards, making MimeKit and MailKit the first - and only - .NET email libraries to support these standards.

If you want to do anything at all related to email in .NET, take a look at MimeKit and MailKit. I guarantee that you will not be disappointed.

October 16, 2014 1:06 GMT

Xamarin Evolve 2014 Re-Cap and Videos

We had an incredible time at Xamarin Evolve 2014, and we hope that you did too!  It was amazing to have 1,200 mobile developers all in one place to learn and celebrate mobile development.  And we hope that those of you who joined from 99 countries to watch the live stream found the sessions educational and inspiring.

Miguel de Icaza on stage during the Xamarin Evolve 2014 Keynote

If you missed the Keynote, or if you just want to re-live the excitement of the incredible announcements made there, the Evolve 2014 Keynote video is now available.

Watch Evolve 2014 Keynote

The Big Announcements

Our mission is to make it fast, easy and fun to deliver incredible mobile apps, and with these Xamarin Evolve 2014 announcements, we are bringing to you the world’s best solution to build, test and monitor your mobile apps:

  • Xamarin Insights: In the Keynote, we announced the release of Xamarin Insights, a real-time monitoring service that helps
  • Xamarin CEO Nat Friedman on stage during the Xamarin Evolve 2014 Keynoteyou improve your apps by tracking crashes and exceptions, and by providing insights into what is happening with your live users.

  • Xamarin Platform Previews: We announced 3 very exciting platform previews that we are making available immediately.
    • Xamarin Android Player: We tackled the single greatest pain point in Android development - the outdated, clunky, slow experience provided by the standard Android emulator. Our new Xamarin Android Player gives your apps the shortest startup time and best possible performance through hardware-virtualization and hardware-accelerated graphics.
    • Xamarin CTO Miguel de Icaza on stage at the Xamarin Evolve 2014 Keynote

    • Sketches: Sketches is a lightweight environment to explore the immediate effects of the code you write. Sketches are ideal to learn new APIs, prototype ideas, and quickly iterate on designs. When you are happy with your code in a Sketch, you can easily copy it into your app. You can also take snippets from your open solution and study them in this isolated live coding environment, making Sketches an incredibly powerful tool for debugging.
    • Profiler: The Xamarin Profiler helps you dissect, analyze, and polish your C# mobile applications. The profiler collects information about the managed side of your Xamarin iOS and Android applications and helps you to figure out where to spend the most time making improvements. You can use it to find memory leaks, resolve performance bottlenecks, and add polish to your applications before getting them out the door.

    Xamarin CEO Nat Friedman on stage at Xamarin Evolve 2014

  • Xamarin Test Cloud Updates: We announced some exciting new features for Xamarin Test Cloud:
    • Xamarin.UITest: Our new automated UI testing framework that harnesses the power of the C# language to create beautiful, readable, first-class test code with all the power of the .NET framework.
    • Improved Capture Tools: Screen recording in Xamarin Test Cloud enables developers to see video playback of an app running through its test cases, capturing the full testing flow, including animations.
    • Test Execution Enhancements: One of the most exciting announcements for Xamarin Test Cloud is hyper-parallel test execution. Currently, when you submit a test run to 10 unique devices, those tests happen at the same time across the devices, but the individual tests run one after the other. Hyper-parallel test execution takes this to the next level by splitting a test suite into chunks and executing the chunks in parallel on equivalent devices. We have seen this drop execution time from around 2.5 hours to just 12 minutes for our own tests.
  • IBM and Xamarin Partnership: Enterprise apps must have a consumer-grade front-end, an enterprise-grade back-end, and a comprehensive mobile software development lifecycle. In order to support the developers in our community building enterprise apps, we’ve partnered with IBM on two initial integrations, available now:
    • IBM MobileFirst SDK for Xamarin: pre-built software library that Xamarin and IBM developers can embed in their mobile apps to connect, secure and manage the apps using IBM Worklight, a part of the IBM MobileFirst portfolio.
    • IBM MobileFirst Add-Ons for Xamarin Studio and Visual Studio: Extensions that enable developers to configure and access the IBM Worklight server from a single environment.
  • Xamarin.Forms Components Ecosystem: Six major .NET component vendors have transformed over 140 existing charts, graphs, gauges, and grids into Xamarin.Forms-compatible, cross-platform mobile controls. Our component vendor partners have created beautiful UI controls that enable mobile developers to create native user experiences that meet the increasing demands of mobile enterprise apps, while saving countless hours developing these views for multiple platforms.

The rest of the conference session videos will be rolled out over the next few weeks, so stay tuned for more great Xamarin Evolve 2014 content!

October 15, 2014 11:29 GMT

Xamarin Insights : Unobtrusive mobile analytics

At the Xamarin Evolve 2014 conference, Xamarin announced their new mobile analytics solution, Xamarin Insights. When you add Insights to your mobile application, you can start tracking exceptions, crashes, user identities, and application events.

One of the best features of Insights is the ability to track the user's actions through the app to be able to trace the conditions that led to an exception. All too often, users will experience an error or, even worse, an app crash. Rarely, these users will email the developer and tell them about the crash, but don't remember any useful information that would help to recreate the exception. By adding calls Xamarin.Insights.Track() to our methods, we can track the events leading up to a particular crash.

Typical Usage

public async Task GetData ()  
{
    Xamarin.Insights.Track ("Enter GetData");

    /* Implement Method */

    Xamarin.Insights.Track ("Exit GetData");
}

private async Task GetLocalData ()  
{
    Xamarin.Insights.Track ("Enter GetLocalData");

    /* Implement Method */

    Xamarin.Insights.Track ("Exit GetLocalData");
}

private async Task GetRemoteData ()  
{
    Xamarin.Insights.Track ("Enter GetRemoteData");

    /* Implement Method */

    Xamarin.Insights.Track ("Exit GetRemoteData");
}

While this does work, it adds a lot of unnecessary noise to the code. Instead of adding line after line of analytics tracking to every method, I prefer to get that boilerplate code out of the way, and let the code focus on the problem at hand.

As I've shown before, I get a lot of use out of Fody in my mobile apps. Fody allows us to control the build time compilation and change the outputted assembly. In this case, we can use Fody's MethodDecorator package to move the Insights tracking logic into a method attribute.

Adding Fody

We'll base our custom attribute on Fody's MethodDecorator attribute, which we can add to our project from Nuget.

Install-Package MethodDecoratorEx.Fody

NOTE : There are two Fody MethodDecorators on Nuget. I'm using MethodDecoratorEx

You'll need to add the declaration to the FodyWeavers.xml file as well.

<?xml version="1.0" encoding="utf-8" ?>  
<Weavers>  
    <MethodDecoratorEx />
</Weavers>  

I wrote up instructions on using Fody with Xamarin Studio

Create Attribute

Next, we'll create a custom attribute to wrap up the Insights code. Each time we enter or leave a method, we'll make a call to Xamarin.Insights.Track().

using System;  
using System.Reflection;  
using MethodDecoratorInterfaces;  
using ArtekSoftware.Demos;  
using Xamarin;

[module: Insights]

namespace ArtekSoftware.Demos  
{
    [AttributeUsage (
            AttributeTargets.Method 
            | AttributeTargets.Constructor 
            | AttributeTargets.Assembly 
            | AttributeTargets.Module)]
    public class InsightsAttribute : Attribute, IMethodDecorator
    {
        private string _methodName;

        public void Init (object instance, MethodBase method, object[] args)
        {
            _methodName = method.DeclaringType.FullName + "." + method.Name;
        }

        public void OnEntry ()
        {
            var message = string.Format ("OnEntry: {0}", _methodName);
            Insights.Track (message);
        }

        public void OnExit ()
        {
            var message = string.Format ("OnExit: {0}", _methodName);
            Insights.Track (message);
        }

        public void OnException (Exception exception)
        {
            Insights.Report (exception);
        }
    }
}

Add Attribute to Methods

Once the attribute is defined, all we need to do is decorate the methods that we want to track. Notice that the implementation of each method is focused simply on the method's logic and not Insights tracking.

[Insights]
public async Task GetData ()  
{
    /* Implement Method */
}

[Insights]
private async Task GetLocalData ()  
{
    /* Implement Method */
}

[Insights]
private async Task GetRemoteData ()  
{
    /* Implement Method */
}

Performance

This may seem like a lot of extra overhead, especially since we're calling out to a remote server. I asked the Xamarin Insights team about this, and got the following answers.

  • When does Insights send its data?
    • If Insights detects a wifi connection then generally we feel free to send data as often as we like, if we are on a Cellular connection we wait a very long time before sending data
  • Does Insights.Track immediately call the server, or are the calls batched up?
    • All data is batched up for a few seconds before sending out to the server
  • Do Insights.Track and Insights.Report call the server asynchronously, or are these blocking calls?
    • All API calls are essentially async, any Insights activity happens in a background thread
  • If queued, does the queue persist across restarts of the app? Restarts of the device?
    • All insights data is journaled to disk, this means track/identify/report/crashes/everything is persistent across restarts. We send out the old data whenever we have a good opportunity to do so, usually after we send out some new data successfully.

Results

The end result of this is that we get really detailed tracking of the events that lead to an exception. This will make finding and fixing errors in our apps faster and more efficient. We get the details of constant tracking without littering our code with tracking calls.

October 14, 2014 6:16 GMT

Standing all day

This article (and sadly I don't remember how I got to it) really struck a chord with me today.

As part of getting my feet wet, my principal suggested I “be” a student for two days: I was to shadow and complete all the work of a 10th grade student on one day and to do the same for a 12th grade student on another day. My task was to do everything the student was supposed to do: if there was lecture or notes on the board, I copied them as fast I could into my notebook. If there was a Chemistry lab, I did it with my host student. If there was a test, I took it (I passed the Spanish one, but I am certain I failed the business one).


I could not believe how tired I was after the first day. I literally sat down the entire day, except for walking to and from classes. We forget as teachers, because we are on our feet a lot – in front of the board, pacing as we speak, circling around the room to check on student work, sitting, standing, kneeling down to chat with a student as she works through a difficult problem…we move a lot.

But students move almost never. And never is exhausting. In every class for four long blocks, the expectation was for us to come in, take our seats, and sit down for the duration of the time. By the end of the day, I could not stop yawning and I was desperate to move or stretch. I couldn’t believe how alert my host student was, because it took a lot of conscious effort for me not to get up and start doing jumping jacks in the middle of Science just to keep my mind and body from slipping into oblivion after so many hours of sitting passively.

I was drained, and not in a good, long, productive-day kind of way. No, it was that icky, lethargic tired feeling. I had planned to go back to my office and jot down some initial notes on the day, but I was so drained I couldn’t do anything that involved mental effort (so instead I watched TV) and I was in bed by 8:30.

That last bit, especially, is how I used to feel at the end of a day at work, and how I felt all thru my university years.

I also do today - today has consistend of being up at 5am, on a ferry at 6, in Wellington by 9, meetings until 4, back home by 8:30. All I crave right at the moment is the quiet of home, and thankfully, thats what we have (aside from the odd noisy bird and the cat).

Today is an exception tho. One day a fortnight. The rest of the time I'm standing.

Since moving to a standing desk, I've stopped having that feeling. I seldom fall asleep at my desk in the afternoon, even if I eat carbs, and I am usually champing at the bit at 6:30pm to go do some exercise. That didn't happen when I sat for 8 hours+ a day.

Thats one of the reasons why I backed this on Kickstarter

Moving to a standing desk has made some huge changes which I didn't expect. Recommended.

October 14, 2014 4:01 GMT

Ada Lovelace Day 2014

Today is Ada Lovelace day, a special occasion to recognize women in our community. I want to take this opportunity to also highlight someone exceptional I have known for a while.

Her name is Andrea Magnorsky.

Andrea Magnorsky

Andrea is an Irish .NET programmer. She’s currently following one of her passion – game development – and is closing production with her studio Digital Furnace (ex-BatCat) on their next title Onikira.

To say that Andrea is a community person is an understatement. In the span of a few years she has not only created popular event/group like Global Gamecraft (game jam contest) or Dublin ALT.NET but she is also continously looking for new ways to teach people through numerous talks and meetups like Functional Kats.

She is curious of everything and always avid to learn. These days you can see her sailing along with F# and functional programming for instance.

It’s no surprise that she was recognized several times in Ireland as a top person in her field. Microsoft also recently awarded her an MVP award.

It’s thanks to people like Andrea that I’m happy to be part of the community that is software development.

Muncho

Muncho would have loved to conclude this but he had another emergency

October 13, 2014 2:15 GMT

Announcing Bike Now on Android, for Seattle's @CyclePronto Bike Share Program

Ever since I first saw Hubway in Boston I was excited for the hopes that one day Seattle would get it’s very own bike share program. Well, 2014 is the year this happens with Pronto Cycle Share is making it a reality.



I was a bit worried that there would be no official app to help track bikes around the Sound, so I decided to take up the challenge. I had a great start with Jérémie Laval’s wonderful Moyeu and morphing it for the Pronto Cycle.

Since Jérémie’s project was open source and built completely with Xamarin, it was easy for me to get off the ground running and leverage several libraries that I am familiar with.

Today, I am pleased to introduce Bike Now for Android and the Pronto Cycle Bike Share program that is launching today in Seattle.


This beautifully crafted app enables you to:

  • Track all Pronto stations on a visual map

  • See past 30 minute history of bike data

  • Favorite stations for quick access

  • Easily see stations nearby

  • Tap to navigate to a station near you





I have many more features planned for the app including Android Wear support, account history, and eventually an iOS and Windows Phone version as well. You can download the app right now on Google Play and learn more at www.bikenowapp.com.
October 13, 2014 1:30 GMT

Episode 18: Securing Mobile Apps with Troy Hunt

Security is more important today than ever, and mobile apps are no different. Troy Hunt joins us to talk about some common mistakes developers make when developing APIs and apps, and some practical approaches to securing them.

Hosts: Greg Shackles

Guests: Troy Hunt

Links:

Thanks to our Sponsors!

Raygun.io

Raygun.io – Exceptional Error Tracking Raygun.io is the fastest and easiest way to track your application’s errors and get the level of detail you need to fix crashes quickly. Notifications are delivered right to your inbox and presented on a beautiful dashboard.

October 13, 2014 12:50 GMT

Introducing Refit 2.0

I've just released a brand new version of Refit, the portable C# library inspired by Jake Wharton's Retrofit.

What's Refit?

Refit (along with http://json2csharp.com) allow you to really quickly create client libraries for Web APIs, by defining their contract in an Interface, and letting Refit do the grunt work of implementing the API for you. Here's an example:

public interface IGitHubService  
{
  [Get("/users/{user}/repos")]
  Task<List<Repo>> ListRepos(string user);
}

Now, use RestService to get an implementation of this Interface that does the work for you:

var client = RestService.For<IGitHubService>("https://api.github.com");  
var repos = await client.ListRepos("paulcbetts");  

Check out the ReadMe for a ton of great examples that demonstrate what you can do with Refit. Here's what's new in Refit 2.0:

Support for Xamarin.iOS 64-bit (#38)

Refit 2.0 uses a completely different system to generate the backing classes for your interfaces. In Refit 1.0, these classes would be generated at runtime using Castle.Core, which worked on most platforms, but fails on any Ahead-of-Time compiled platform, such as Xamarin.iOS.

Refit 2.0 instead generates classes at compile-time, by analyzing your app's source files with Roslyn, and generates a new RefitStubs.cs file that will be compiled along with your app. As well as enabling Xamarin.iOS 64-bit support, this class is easily subclassed and extended via partial classes, so customizing individual method behavior is now much easier.

Unfortunately, because of build system limitations, this method doesn't work with Xamarin.iOS 32-bit - you'll need to upgrade to the new Unified API before this will work in your app.

Support for Windows Store / Windows Phone 8.1 Universal Apps (#59, thanks @bennor)

Because of the compile-time code generation mentioned above, Refit 2.0 now has full support for WinRT (Windows Store) and Windows Phone 8.1 Universal applications too!

Observables in Refit are now Cold (#56, thanks to @balauru for some of the work)

Observables in Refit 1.x are backed by AsyncSubject, meaning that they replay a single result to subscribers, even after the network request ends. In Refit 2.0, Observables now do no work until Subscribed to, and each Subscription will generate a new network request, in line with Retrofit. Observables in Refit 2.0 now also will cancel network operations if the Subscription is disposed, allowing you to efficiently cancel requests if they are no longer needed.

Before:

var observable = someRestService.ReturnsAnObservable();  
var result1 = await observable;  
var result2 = await observable;

// result2 is just a replayed result1, the network request was made when
// we called ReturnsAnObservable regardless if anyone cared.
result1 == result2;  
>>> true

After:

// Does nothing
var observable = someRestService.ReturnsAnObservable();

// Makes a web request
var result1 = await observable;

// Makes a *different* web request
var result2 = await observable;

result1 == result2;  
>>> maybe?

Form Property Aliasing (#55, thanks @bennor)

When POSTing bodies serialized via BodySerializationMethod.UrlEncoded, the AliasAs tag now also works on properties in the model class:

Before:

public interface IMeasurementProtocolApi  
{
    [Post("/collect")]
    Task Collect([Body(BodySerializationMethod.UrlEncoded)] Measurement measurement);
}

public class Measurement  
{
    public string t { get; set; } // This isn't even the worst of them
}

await api.Collect(new Measurement { t = "what even is t?" });

After:

// This part doesn't change
public interface IMeasurementProtocolApi  
{
    [Post("/collect")]
    Task Collect([Body(BodySerializationMethod.UrlEncoded)] Measurement measurement);
}

// This stuff does
public Measurement  
{
    [AliasAs("t")] 
    public string Type { get; set; }
}

await api.Collect(new Measurement { Type = "event" });  
October 12, 2014 2:44 GMT

A Tale of Connected Dots

This past week, we organized Evolve 2014 in Atlanta to talk about all things mobile with Xamarin.

Being a mobile conference, we of course made our own app so that attendees could track out the sessions and the geography of the event.

We also launched something a bit different in the form of a treasure hunt app. Thanks to Estimote, we used a combination of iBeacon and QR codes spread throughout the conference intertwined with challenges along the way until you reach the end of the quest and a special prize.

The main interface of that quest app is a serie of connected dots:

Evolve Quest screenshot

As you progress through the game, the content scrolls naturally to reveal more odd-shaped arrangement of those dots.

Originally, this screen was just a big tall image containing everything. This is suboptimal on Android for a couple of reason like some graphic chip not supporting big “texture” or simply the need to rescale at runtime on most screen.

Ultimately it’s also not fun because there is really nothing you can do with a big image.

Hint: this is NOT what we shipped (on Android at least).

Rather, what attendees could see on their Android phone at the conference was this:

A much more satisfying, softly animated, connected system of dots. The current game position is also highlighted with a discrete pulse.

We will open-source the entire Quest application at some point but I wanted to share how we did that specific bit that is entirely exclusive to Android.

View Source Code

Since this is a really custom animation, it’s a bit different than the other type of animation samples I have already shown.

For this type of thing, I usually rely on a very simple animator that gives me a floating value between 0 and 1 so that I can do my own tweening in code. I also manage to pass this value by hijacking one of the standard view animatable property so that I don’t need to expose more information to the Java bridge:

1
2
3
4
5
6
7
8
9
10
11
12
13
// Interpolator instantiation
shiverAnimator = ObjectAnimator.OfFloat (this, "scaleX", 0, 1);
shiverAnimator.RepeatCount = ValueAnimator.Infinite;
shiverAnimator.AnimationRepeat += (sender, e) => shiverIndex++;

// Property hijack
public override float ScaleX {
	get { return currentShiverInterpolation; }
	set {
		currentShiverInterpolation = value;
		Invalidate ();
	}
}

In our case, I then use this value to compute for each drawing pass an offset that is added to the base position of every dots:

1
2
3
4
5
6
7
8
9
10
11
// Expressed in dp units
int[] shiverOffsets = new[] { 9, 3, -8, 4, -7, 6 };

// Extra applied offset code
int ApplyShivering (int dotIndex, int value)
{
	var off = shiverOffsets [(dotIndex + shiverIndex) % shiverOffsets.Length]
		* currentShiverInterpolation;
	value += (int)Math.Round (off);
	return value;
}

The wave that you see on the highlighted pin comes from a GradientDrawable that I create from a shape drawable XML definition as follow:

1
2
3
4
5
6
7
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
	android:shape="ring"
	android:useLevel="false"
	android:innerRadiusRatio="2">
	<solid android:color="#99ffffff" />
</shape>

The reason for using a drawable like this is to avoid redoing common drawing code and also taking advantage of the ring shape type automatic radius scaling (notice the innerRadiusRatio attribute) to create a nice spreading effect as the ring grows larger.

The ring size and color is dynamically computed from a slightly interpolated (quadratic or accelerated) value coming from our shared shiver interpolator:

1
2
3
4
5
6
7
8
9
10
11
var dur = shiverAnimator.Duration / 4;
var fraction = (float)(shiverAnimator.CurrentPlayTime % dur) / dur;
// Cheap interpolation
fraction *= fraction;

var rippleRad = (int)(radius * (5 * fraction + 1)) - 8;
ripple.SetBounds (x - rippleRad, y - rippleRad, x + rippleRad, y + rippleRad);

var color = Color.Argb ((int)Math.Round (0x99 * (1 - fraction)),
                        0xFF, 0xFF, 0xFF);
((GradientDrawable)ripple).SetColor (color.ToArgb ());

If you have been to my Mastering Time and Space session, you’ll likely also have detected the presence of a custom interpolator in there that is set on the shared shivering animator. The code is following:

1
2
3
4
5
6
7
8
class TriangleWave : Java.Lang.Object, ITimeInterpolator
{
	public float GetInterpolation (float input)
	{
		var t = input * 2;
		return (float)(2 * Math.Abs (t - Math.Floor (t + 0.5)) * (1 - 2 * Math.Floor (t)));
	}
}

This interpolator generates a triangle pattern that is repeatable (i.e. it both starts and ends at the same position for the dot) so that the animation can run continuously:

Triangle curve

October 10, 2014 6:10 GMT

Xamarin Evolve: Day 4

Some great sessions today- here are some of the highlights:


Think Like a Hacker!

This was one of the most eye opening for many, with Darren Cathey going into great detail on security and protection against app hacking techniques to a packed room. These figures were quoted:

Off the top 100 paid apps in the App Store and on Android:

Android: 100% have hacked versions available in other stores
iOS: 56% have hacked versions available in other stores

A lot of ground was covered in here, from code obfuscation to method swizzling, with some jailbreak detection and hex editing thrown in.

Azure Mobile Services

Paul Batum gave a very detailed presentation of Azure Mobile Services, covering development of the service in Visual Studio, usage of the SDK from within Xamarin iOS and Xamarin Android, and using Azure Mobile Services to call out to an on premise database - on Paul's demo laptop, all running smoothly.

Shipping Apps in China

Some of the difficulties in shipping an app to a different country in a different language were highlighted, as well as the pressing need for consideration of cultural differences.
Jonathan Peppers also talked about some of the difficulties of handling in-app purchases in China, as they're typically paid for as part of the mobile network charges and different app stores, and mentioned that an app purchased from one app store can be updated from a different app store if that second store gets the update notification out first, leading to a redirection of the revenue. One implication of this is that testing needed to be carried out over the all the main networks using active Chinese SIM card - i.e. in China.
This app store fragmentation story was very interesting given some of the points raised in the "Think Like a Hacker" presentation earlier in the day.

The day finished, once again, with a Xamarin Party - this time a southern style barbecue complete with live music and a variety of activities.