New Xamarin.Forms Control: WaitingPage

Last week I got into a conversation with Christine Blanda on the Xamarin Forms forum about creating a page that had a built-in Activity Indicator that could be enabled/disabled by just setting properties.  It turns out that I was at a point in one of my projects where I needed just such a component so I spent a little time, and with Christine’s help, and created WaitingPage.

The source is available on GitHbg and will probably be integrated in with the XLabs project after a little more testing and feedback.

Properties

The following properties are available:

IsWaiting (bool, bindable)

true Shows the waiting indicator, false hides the waiting indicator.

ShowLoadingFrame (bool, bindable)

true Wraps the waiting indicator in a frame. false simply shows the waiting indicator by itself.

ShowLoadingMessage (bool, bindable)

true Shows a message along with the waiting indicator, false simply shows the waiting indicator by itself.

ShadeBackground (bool, bindable)

true will shade the background of the page a light grey while the indicator is active, false will not employ shading.

LoadingMessage (string, bindable)

Allows you to specify a waiting message along with the waiting indicator. The default is Loading….

WaitingOrientation (StackOrientation, bindable)

Shows the waiting indicator either vertically or horizontally. If you only have the indicator, this properly is pretty much ignored. But if you are using a waiting message, it will display the message above the indicatore (vertical) or to the right of the indicator (horizatontal).

Vertical Orientation

image

Horizontal Orientation

image

Indicator (ActivityIndicator)

You may specify your own pre-created ActivityIndicator if you wish. If one is not specified, a new one will be created.

Usage

Just inherit from WaitingPage instead of ContentPage:

 public class LoginPage : WaitingPage

Then set the various properties:

 ShowLoadingFrame = true;
 ShowLoadingMessage = true;
 ShadeBackground = false;
 LoadingMessage = “Logging in…”;
 IsWaiting = false;
 WaitingOrientation = StackOrientation.Vertical;

To show the indicator immediately when the page appears, just set IsWaiting to true.

To hide the indicator, just set IsWaiting to false.

Dynamics CRM 2015 Spring: Delete Plug-in Trace Log Records

So I am digging around the Dynamics CRM 2015 Spring Update, as I am apt to do, when I ran across something that needs to be changed.

There is a recurring bulk delete job that automatically deletes any plug-in trace log records older than one day, as you can see below:

image

This is a little too quick for my taste, so I would advise changing this value to be something longer, like seven or thirty days.

The real issue is that we cannot change the query used to select the jobs, but we can change the recurrence pattern.

Modifying a Recurring Job

To change a recurring job, perform the following steps:

1. Navigate to Settings, Data Management, Bulk Record Deletion.

2. Change your view to be: Recurring Bulk Deletion System Jobs

3. Open the bulk delete job in question.

4. Click the Actions button, the select Modify Recurrence. You will see the following dialog:

image

5. Change he following settings:

  • Run the job after every X days
  • Start time

Choose values that fit your organization.

6. Click the OK button.

That should change the recurrence so that the interval between runs is longer.

Query an NTP server for the current internet time using Xamarin Forms

There were a couple of threads (here, and here) this week regarding querying an Internet-based time server using Xamarin forms.

The first thing you need to do is download Sockets for PCL from Nuget, written by Ryan Davis. The source may be found here.

Using Ryan’s updated sample code from the second formum thread, I’ve created a sample project using this code in a Xamarin Forms project in case anyone else needs this functionality.

working with the ListView.GroupHeaderTemplate

One of my current projects makes used of ListView Grouping and for quite some period of time, I could not understand why my custom header template was not working, when code from other people’s projects that I had seen worked just fine.

So yesterday, I decided I had had enough and spent a couple of hours working section by section, line by line, to break an working sample then fix it again.  I learned something very important in the process.

A Working Sample

I started off with @JamesMontemagno’s Enhancing Xamarin.Forms ListView with Grouping Headers and customized it to make it look and function exactly as my project was designed.

Locating the Issue

The problem actually came down to these two properties:

 list.GroupDisplayBinding = new Binding("Key");
 list.GroupHeaderTemplate = new DataTemplate(typeof (HeaderCell));

Which the documentation clearly states as:

GroupHeaderTemplate is mutually exclusive with ListView.GroupDisplayBinding. Setting this property will set ListView.GroupDisplayBinding to null.

Which works exactly as it says it does.

The problem is with this code:

 list.GroupHeaderTemplate = new DataTemplate(typeof (HeaderCell));
 list.GroupDisplayBinding = new Binding("Key");

Again, the documentation clearly states:

This property is mutually exclusive with ListView.GroupHeaderTemplate property. Setting it will set ListView.GroupHeaderTemplate to null.

I didn’t happen to see that comment. Either that, or the documentation was updated later with that information and I never saw it.

The Solution

So the easiest solution to this issue is to not set the GroupDisplayBinding property. In all probability, your header template looks something like this:

  public class HeaderCell : ViewCell
  {
    public HeaderCell()
    {
      Height = 25;

      var title = new Label
      {
        FontSize = Device.GetNamedSize(NamedSize.Small, this),
        FontAttributes = FontAttributes.Bold,
        TextColor = Color.White,
        VerticalOptions = LayoutOptions.Center
      };

      title.SetBinding(Label.TextProperty, "Key");

      View = new StackLayout
      {
        HorizontalOptions = LayoutOptions.FillAndExpand,
        HeightRequest = 25,
        BackgroundColor = Color.FromRgb(52, 152, 218),
        Padding = 5,
        Orientation = StackOrientation.Horizontal,
        Children = { title }
      };
    }
  }

So you have already got your binding within the template, so it is not necessary to set the GroupDisplayBinding property.

 

Lessons Learned

And yes, you can probably guess where this is headed:  Read the damn manual!

Beacon Idea #7: Where did they go?

Xamarin is holding contest to get ideas of how beacons (iBeacons) can be used to context-aware mobile applications.

I have been doing a lot of research on beacons so I thought I’d share some of my ideas.

The Concept:

In the last concept, Beacon Idea #6: Your bag has arrived, we discussed how to receive an alert when a beacon came within range. If we reverse that concept, we can track beacons and alert you when they move past a specific range. This application can be applied to pets, children, the elderly, etc.

The Problem

You can’t always keep your special people within line of sight, but you need them to be safe and know where they are.

The Solution

Add a small beacon to their collar or clothing, depending on the situation, then set your application to warn you should they move past a predetermined (and agreed upon) distance from you. The standard range of a beacon is around 70 meters, depending on environmental factors, so your boundary should be well within that range.  And of course, you should always verify the range physically so you can adjust your boundary should the signal be degraded due to obstructions, etc.

Beacon Idea #6: Your bag has arrived

Xamarin is holding contest to get ideas of how beacons (iBeacons) can be used to context-aware mobile applications.

I have been doing a lot of research on beacons so I thought I’d share some of my ideas.

The Concept: Notify you when your bag is at the bag claim

It’s late, you’ve had a long trip, and now you are standing around at the luggage carousel waiting for your bag to arrive.

The Problem

You would like to be just sitting around rather than be standing around, waiting for your bag.

The Solution

Apply a low-profile beacon, like the Estimote Sticker to the bag and create an app that will automatically notify you when it gets within range of the phone.

Beacon Idea #5: Retail, Analysis, and Dynamics CRM

So if you have been reading my blog frequently over the past few months you will notice that I have been doing  lot of mobile-related development, mostly with the Xamarin platform (which I absolutely love, btw).

One of the projects that I’m working on will involve the use of beacon, or iBeacon, technology.  I thought I would spend a little time today discussing how you can unite beacons and Dynamics CRM to collect a variety of information about your prospects and customers.

A Bit about Beacons

iBeacon is Apple’s technology for indoor positioning, where you need a finer-grained position that can be achieved using GPS. Apple decided to make the iBeacon specification available to other vendors and companies like Qualcomm and Estimote have products that are iBeacon compatible.

There are alternative beacon technologies available that are not iBeacon compatible, so for the sake of simplicity, I’ll just refer to everything as a “beacon” to keep things generalized.

Beacons are just transmitters that broadcast their position using Bluetooth Low Entergy, or BLE.

The intelligence dealing with where the beacons are located and their distance from the receiver, must be handled within an application that has connected to a mobile device’s BLE signal.

Currently, late models of iPhone, Android, and even some Windows Phones are equipped with a BLE interface which will allow you to write applications that can search for an recognize beacons.

Again, the beacon just announces, “here I am” and the application on the mobile device does the real work of “seeing” the beacon and deciding upon the next course of action.

The Retail Connection

One of the most talked about areas for the use of beacons is in a retail environment – and the possibilities are truly endless. 

Here is a sample scenario:

Customer Visit Tracking

It is possible to install beacons various locations within a store and track the following:

  • When the customer entered or exited the store
  • The amount of time spent within the store
  • The departments visited
  • The amount of time spent within a department
  • Purchases

All of these data points are primarily centered around a customer having an application on their phone that can interact with the beacons and send the data back the the cloud-based collection system.

Data Analysis

The one thing you really need to be careful of when capturing beacon data is the amount of data produced. The data flow will dictate the design of your beacon data storage and what tools you use to perform the analysis.  There are several possibilities here:

  • Estimote has built-in analytics for their beacons
  • You can roll your own using Azure App Services to both record the data and perform analysis
  • Add it to your internal SQL Server data system and use tools such as PowerBI to perform the analysis

The Dynamics CRM Connection

Let me state right up front that Dynamics CRM is not where you put your beacon data. There will, in most cases, be too much data and there are better, faster, and cheaper alternatives for both the storing and analysis, like the ones mentioned above.

After you have collected the data and performed the analysis is when you connect it to Dynamics CRM.  The primary use of any Customer Relationship Management system is to record data about a customer:

  • When do they shop?
  • What do they like to buy?
  • Are they purchasing for them selves or a family member?
  • Do they have a brand-preference or a deal-preference?

Use your analysis tools to deliver that type of information by using data obtained from their purchase history, the beacon data, and your web site. That is how you can improve the interaction of your company with the customer.

Make sure your marketing department makes good use of this new data and delivers to the customer the types of offers that make sense to them.

The key point here is value. You need to constantly be providing value to the customer.  It is not always about you; and yes, you need to sell things to stay in business, but it is much easier to sell to people who want to buy.

The Big-Brother Creepiness Factor

This type of process is fairly high on the big-brother creepiness factor but is really saved by the fact that the customer has opted-in to this program by:

  1. Installing the application on their phone
  2. Setting their personal preferences to allow their activities to be tracked

Physical Retail vs. Online Retail

What is so very ironic about this entire conversation is that Online retailers already collect this type of data each and every time a customer visits their web site.  Some are much better than others, but they all do it to a certain extent.

Deploying a technology like beacons to a physical retail store gives that company the ability to collect, and hopefully use wisely, the same types of data that their web site produces.  When you combine those two sets of data together, you can generate a more complete picture of the customer.

Conclusion

All of these things we’ve discussed today are fairly easily done, just remember one extremely key point: Do not be a pest. 

One one likes a pest, either in the online or physical retail world.

Taking screen shots of a mobile application

There was a really great thread on the Xamarin Forms forum yesterday regarding taking screen shots of your mobile application. I thought I would share this information here to summarize the conversation.

From Outside the Application

Greg Shackles wrote a great article about using Xamarin UITest to generate screen shots using the built-in functionality of the testing mechanism.

Fredy Wenger recommends using SnagIt, which I also use for all of my screen shots, regardless of platform.

From Inside the Application

Daniel Hindrikes created a ScreenshotManager component to handle the work from within your application. This work is documented here.

Norman Macay also pointed us to a previous post about collecting screen shots for Android.

All in all, there are a variety of methods, you just need to select the one that works for you, given your situation.

Beacon Idea #4: Restaurant Check-in and Loyalty Program

Xamarin is holding contest to get ideas of how beacons (iBeacons) can be used to context-aware mobile applications.

I have been doing a lot of research on beacons so I thought I’d share some of my ideas.

The Concept: Restaurant Check and Loyalty Program

You would like to create a program that rewards your regular customers and offers them rewards, such as free food or drinks, the more often they drop in.

The Problem

You need to track customer visits without resorting to any manual operations (you’ve got a restaurant to run),

The Solution

This solution will involve creating an application for your store that will provide a variety of functionality, but for this conversation, we’ll just discuss the part involving beacons.

You place a beacon near the front of the restaurant, probably in the hostess stand and encourage your regular customers to download your free restaurant application. Part of the functionality of the application is to monitor for the “check-in” beacon. When a customer walks into the restaurant, the application locates the beacon and sends a check-in report back to the web service that handles the check-process, which rests in Windows Azure.

After recording the check-in event, the web service increments the “reward counter” then checks to see if it is greater than seven. If so, then a notification is sent back to the customer’s phone (using Azure Notification Hubs) which is displayed in the application as a coupon giving the customer a free item from your menu. The reward counter is reset to zero and the reward process will restart upon the next visit.

Sharing information and lessons learned with other developers

Sign up for our new KnowledgeBits service and get news, tips and tricks and more, delivered straight to your inbox.