Steps to Create a Device Channel For Mobile Devices in SharePoint 2013

Introduction

Here, we will create a device channel in SharePoint 2013 that will identify Android, iOS, BlackBerry, WebOS and Windows.

Mobile devices. We will do device channel creation in one of the following 3 ways.

Using Site Settings

In order to view and modify the device channels for a SharePoint site, the SharePoint Server Publishing Infrastructure site collection feature and SharePoint Server Publishing site feature must be activated.

Step 1

Navigate to the site in your preferred web browser.

Step 2

Select Site Settings from the Settings menu.

Step 3

Select Device Channels from the Look and Feel section. You can also navigate to the Device Channels page from the Design Manager page.



Step 4

Select New Item.

Step 5

Provide a Name, Description and Alias for the device channel.

Specify the Device Inclusion Rules to be included in the device channel.

  • Android
  • iPad
  • iPod
  • iPhone
  • BlackBerry
  • IEMobile
  • WebOS

Step 6

Mark the Active checkbox and click on Save. Device channels are created and stored in the /Device Channels SharePoint list in the root Site of a site collection. When an incoming browser request is received, SharePoint checks whether the incoming user agent matches any of the Device Inclusion Rules before selecting the master page to use.



Using PowerShell

Use the following procedure to create a device channel for mobile devices using PowerShell.

Step 1

Get the site using the Get-SPWeb Cmdlet.

  1. $web = Get-SPWeb http://sharepoint/site.  

Step 2

Get the Device Channels list.

  1. $list = $web.Lists["Device Channels"

Step 3

Add a new SPListItem item to the Items collection of the list.

  1. $item = $list.Items.Add ()  

Step 4

Assign the values to each of the properties on the SPListItem item.

  1. $item["Name"] = "PowerShell"  
  2. $item["Alias"] = "PowerShell"  
  3. $item["Description"] = "PowerShell Channel"  
  4. $item["Device Inclusion Rules"] ="Android`niPad`niPod`niPhone`nBlackBerry`nIEMobile`nWebOS"  
  5. $item["Active"] = $true  

Step 5

Call the Update method on the list to update the Items collection.

  1. $item.Update()  

Step 6

Use the Dispose method to discard the SPWeb object.

  1. $web.Dispose()  

Using Server-Side Object Model

Use the following procedure to to create a device channel for mobile devices using the server-side object model.

Step 1

Open the site collection containing the site in a using statement.

  1. using (var site = new SPSite("http://sharepoint/site")) 

Step 2

Open the site in a using statement.

  1. using (var web = site.OpenWeb())  

Step 3

Get the Device Channels list.

  1. var list = web.Lists["Device Channels"];  

Step 4

Add a new SPListItem item to the Items collection of the list.

  1. var item = list.Items.Add();  

Step 5

Assign the values to each of the properties on the SPListItem item.

  1. item["Name"] = "Code";  
  2. item["Alias"] = "Code ";  
  3. item["Description"] = "Code Channel";  
  4. item["Device Inclusion Rules"] ="Android\niPad\niPod\niPhone\nBlackBerry\nIEMobile\nWebOS";  
  5. item["Active"] = true;  

Step 6

Call the Update method on the list to update the Items collection.

  1. item.Update();