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.
Step 2
Get the Device Channels list.
- $list = $web.Lists["Device Channels"]
Step 3
Add a new SPListItem item to the Items collection of the list.
- $item = $list.Items.Add ()
Step 4
Assign the values to each of the properties on the SPListItem item.
- $item["Name"] = "PowerShell"
- $item["Alias"] = "PowerShell"
- $item["Description"] = "PowerShell Channel"
- $item["Device Inclusion Rules"] ="Android`niPad`niPod`niPhone`nBlackBerry`nIEMobile`nWebOS"
- $item["Active"] = $true
Step 5
Call the Update method on the list to update the Items collection.
Step 6
Use the Dispose method to discard the SPWeb object.
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.
- using (var site = new SPSite("http://sharepoint/site"))
Step 2
Open the site in a using statement.
- using (var web = site.OpenWeb())
Step 3
Get the Device Channels list.
- var list = web.Lists["Device Channels"];
Step 4
Add a new SPListItem item to the Items collection of the list.
- var item = list.Items.Add();
Step 5
Assign the values to each of the properties on the SPListItem item.
- item["Name"] = "Code";
- item["Alias"] = "Code ";
- item["Description"] = "Code Channel";
- item["Device Inclusion Rules"] ="Android\niPad\niPod\niPhone\nBlackBerry\nIEMobile\nWebOS";
- item["Active"] = true;
Step 6
Call the Update method on the list to update the Items collection.