Develop iOS and Windows Store Apps using Office 365/SharePoint 2013

wrackbaaΚινητά – Ασύρματες Τεχνολογίες

10 Δεκ 2013 (πριν από 3 χρόνια και 4 μήνες)

61 εμφανίσεις

Develop
iOS

and Windows Store Apps using
Office 365/SharePoint 2013

Kashif

Imran

Kashif_imran@hotmail.com

Agenda


What are
iOS

and Windows Store Apps


Why build
iOS
/Windows Store Apps


Why use SharePoint/Office 365?


Demo
-

Service Request Management App for
iOS

and Windows Store


Development Platform


SharePoint APIs


Which API to Use?


SharePoint CSOM


Demo


Customer Portal Code Review


Office 365 Authentication


REST/
OData


Demo


Staff Portal Windows Store App Code Review


Demo


Staff Portal
iOS

App Code Review


Questions?




What are
iOS

and Windows Store Apps


Immersive


Touch First


Full screen experience without any chrome


Support different layouts and


What are
iOS

and Windows Store
Apps
(cont.)


Sandboxed


Distributed
via App Store/Windows
Store


Application Styles


Productivity applications (Contacts, Photos)


Utility applications (Weather, Stocks)


Immersive applications (Living earth, Carpenter)



Why build
iOS

or Windows Store Apps


Web apps vs. Native
Apps


Advanced
BI Visualization


Offline
Scenarios


Device
specific
features


Examples:


Facebook (HTML5 or Native)


YouTube




Mobile Development Characteristics


Compact screen


Different device orientations


Limited memory


Usually one app at a time


Minimal help


No Quit button


External events interrupt program flow


Store state when stopping


Why use SharePoint/Office 365?


Team productivity


Document management


Tailored solutions


Cot effective file sharing


Privacy


Security


Compliance


Anywhere anytime access to data


Rich set of capabilities


Less training


Deploy
your
way (cloud, on
-
prem
, hybrid)


Financially backed 99.9% backed SLA


Enterprise grade support

Service Request Management App for
iOS

and Windows
Store

SharePoint 2013

Office 365

Customer Portal

Customers
submit service
requests from
public facing site.


Staff Portal

Windows Store
App

Staff Portal

iOS

App

Development Platform


Windows Store Apps


Windows 8


HTML 5 and JavaScript


XAML and C#/VB/C++


DirectX and C++ (Games)


Visual Studio 2012


$49 for Individual, $99 Companies


iOS

Apps


Mac
-

OS X


Objectv
-
C


Xcode


iOS

5+ support ARC


$99

Cross
-
Platform mobile apps


Xamarin


Miguel de
Icaza


Mono: open source ECMA standard compliant .NET
Framework compatible set of tolls including Compiler
and CLR


MonoTouch:C
# and .NET based application that run on
iPhone.
MonoTouch

apps are compiled down to native
machine code.


iOS
, Android and Mac apps in C#


Xamarin

Studio or Visual
Studio



SharePoint APIs


Server Object Model


Client Object Model


.NET Client OM


Silverlight (and Mobile) Client OM


JavaScript Client OM


REST/
OData

Endpoints


ASP.NET (
asmx
) web services


Only supported for backward compatibility


Direct
Remote Procedure Calls (RPC) calls to the
owssvr.dll


Only supported for backward compatibility



Which API to use?


Type of Application


Farm
Solutions (w3wp.exe)


With great power comes great responsibility


Sandboxed Solutions (SPUCWorkerProcess.exe)



SharePoint sandboxed solutions are deprecated in SharePoint 2013 in
favor of developing apps for SharePoint, but sandboxed solutions can still
be installed to site collections on SharePoint
2013.” MSDN


SharePoint Apps (SharePoint
-
Hosted, Cloud
-
Hosted)


Custom Logic in apps is distributed down to the client or up to the cloud


Must use one of the client object models or REST/
OData

endpoint


External Applications


LAMP web apps,
iOS
/Android apps


Existing Skills


JavaScript, ASP.NET, REST/
OData
, Silverlight, PowerShell


Target Device

SharePoint Extension Types

Source: MSDN

SharePoint CSOM


API to build remote applications


Contains subset of functionality that is available in Server Object Model


Many administrative functions are not available in CSOM


Underlying communications is encapsulated in the runtime


CSOM Implementations


.NET Client
OM


Silverlight Client OM


JavaScript Client OM


Type names
are
similar
to Server Object
Model but do not have prefix
SP as
type names
in Server OM



Server OM

Managed/Silverlight
Implementation

JavaScript
Implementation

SPContext

ClientContext

SP.ClientContext

SPSite

Site

SP.Site

SPWeb

Web

SP.Web

SPList

List

SP.List

SPListItem

ListItem

SP.ListItem

SPField

Field

SP.Field

SharePoint CSOM

CSOM Updates in SharePoint 2013


client.svc

has been extended to support direct
RESTful

calls


OData

complaint implementation and support of HTTP GET, PUT,
POST, MERGE and DELETE


New APIs for Server functionality


Business Data


Search


Publishing


User Profiles


Taxonomy


Feeds


Sharing


Workflow


E
-
Discovery


IRM


Analytics

CSOM in SharePoint 2010


Direct access to
client.svc

is not supported


ListData.svc

for REST calls and available in SP2013 only
for backward
compatibility


CSOM Architecture

.NET Client OM


Queries are sent to the SharePoint server in batches


Microsoft.SharePoint.Client.dll


Microsoft.SharePoint.Client.Runtime.dll


Root
\
15
\
ISAPI


ClientContext


Load


Populates
objects in place


LoadQuery


Returns
results for
query


ExecuteQuery

or
ExecuteQueryAsync

on
ClientContext


Collection and even some non collection properties are not loaded by
default



.NET Client OM
-

Load

.NET Client OM
-

LoadQuery

Demo


Customer Portal


Office 365 Authentication

Source: Omar
Venado’s

Blog
:

http
://blogs.msdn.com/b/omarv/archive/2012/10/25/windows
-
8
-
store
-
apps
-
office
-
365
-
enterprise
-
preview
-
sharepoint
-
online.aspx

Use Managed CSOM in Windows Store App


Add new project using Windows Runtime Component
template in VS2012


Add references to
Microsoft.SharePoint.Client

and
Microsoft.SharePoint.Client.Runtime


Access Managed CSOM from C# or
Javascript

in
Windows Store App


REST


REST VS SOAP


Lightweight and easier to implement for various types of
potential clients


Various open source JavaScript libraries that support
REST based programming


Facebook, LinkedIn, Twitter all has REST APIs


Results are returned as JSON VS ATOM


Results can be cached by proxy servers


SOAP: Same URL, request is in header


REST: Separate URL for different queries or operations


OData

(Open Data Protocol)


Web protocol for querying and update data


Build upon web technologies, HTTP,
AtomPub

and JSON


Ignores some of the REST constraints


Data is served up as XML or JSON in Atom Feed


Microsoft, SAP
AG, IBM, Citrix, Progress Software and
WSO2


OData

services: Netflix, Azure


OData

clients: Excel 2010/2013

OData

Terms and Concepts

EDM

OData

Entity Set

Collection

Entity Type

Entry

Property of an Entity Type

Property of Entry

Navigation Property

Link


Built on Entity Data
Model


Collections contain Entries like Tables contain
Rows


Collections can be associated like Tables can be
related


Entry has properties like Table Row has
columns


Collections always have keys like Tables may have
keys


Browse to service root of
OData

service usually returns all
available
Collections

OData

URIs


Service root URI


Resource path


Query string options

Source: odata.org

Northwind

OData

Queries


Available Collections


http
://services.odata.org/Northwind/Northwind.svc
/


Metadata:


http
://services.odata.org/Northwind/Northwind.svc/$
metadata


Query Entity Set (Collection)


http
://
services.odata.org/Northwind/Northwind.svc/Customers


Customer With Single Entry


http://services.odata.org/Northwind/Northwind.svc/Customers('LETSS')


Get One Property:


http
://services.odata.org/Northwind/Northwind.svc/Customers('LETSS')/Address


Value of a Property:


http
://services.odata.org/Northwind/Northwind.svc/Customers(
'
LETSS
')/
Address/$
value


Collection of related Links without actual entries:


http://services.odata.org/Northwind/Northwind.svc/Customers(
'
LETSS
')/$links/Orders


Related Entries:


http
://services.odata.org/Northwind/Northwind.svc/Customers(
'
LETSS
')/
Orders(10643)/
O
rder_Details


Query Language


Options: $filter, $sort, $
orderby
, $top, $expand, $skip, $take,
$metadata…


Operations:
eq
, ne,
gt
,
ge
,
lt
, le, and, or, not, mod, add, sub


Functions:
startswith
, substring, replace,
tolower
, trim, round,
ceiling, day, month, year,
typeof
,…


Top 3 Customer from USA Order By
ContactName


http://services.odata.org/Northwind/Northwind.svc/Customers?$filte
r=Country
eq

'USA'&$
orderby
=
ContactName
&$
top=3


Return related Entries Inline


http://services.odata.org/Northwind/Northwind.svc/Customers('LET
SS')/$links/Orders


Get Data in JSON Format


http
://services.odata.org/Northwind/Northwind.svc/Customers
(
'LET
SS'
)?$
expand=Orders&$format=JSON

CRUD Operation and HTTP Verbs


Standardize CRUD operations using HTTP verbs such as
GET, PUT, POST and MERGE


Methods are mapped into Navigator operations via GET
(
list.getByTitle
)

CRUD Operation

HTTP Verb

Read

GET

Create

POST

Update

PUT or MERGE

Delete

DELETE

SharePoint REST URLs


_
api

=> _
vti_bin
/
client.svc


_
api
/web/lists


_
api
/web/lists/lists(
guid
)


_
api
/web/lists/
getByTitle
(‘Announcements’)


_
api
/web/lists/
getbytitle
(‘Announcements’)/items(2)/
Field
ValuesAsHtml
/$select=
Title,Author


_
api
/web/
getAvailableWebTemplates
(
lcid
=1033)


_
api
/web/?$select=
title,id


_
api
/web/lists/
getByTitle
(‘
mylist
’)?$select=
title,firstname


_
api
/web/lists/
getByTitle
(‘customers’)?$select=
title,firstna
me&startswith
(Title, ‘p’)

Demo
-

OData

Queries in Browser


Demo

OData
:
ATOMPub

Format


ATOMPub
: The Atom Publishing Protocol


Application level protocol for publishing and editing web
resources.


Based on HTTP transfer of Atom
-
formatted representations.


ACCEPT = application/
atom+xml


XML Parsing on client side (Easy in Managed Code)


XML is default for SharePoint REST calls



ATOM
-
Formatted Data Example

JSON


Lightweight
data
-
interchange format


Easy for humans to read and
write


Easy for machines to parse and generate


ACCEPT
=
application/
json;odata
=verbose


Client libraries like
datajs


Hierarchically in arrays and /or
in

key
-
value
storage


Characters [] enclose arrays


{} key value pairs


“” enclose text values


Helpful Classes in
iOS

for REST Calls


NSURLConnection


(
synchronous, Asynchronous, delegate methods)


NSURLRequest


NSURLResponse


NSError


NSData


NSJSONSerialization


NSDictionary


NSArray


JSON Item
Converstion
:


Array
of
Items =>
NSArray


Key
-
Value storage
=>
NSDictionary


String

=>
NSString


Numbers
=>
NSNumber


Null values
=>
NSNull


NSXMLParser

Helpful Classes for Windows Store App
REST Calls


HttpClient


CookieContainer


JsonObject


JsonArray


Dictionary<string,
IJsonValue
>



Updates and the Form Digest


Form Digest can be acquired through


http://site/_
api/contextinfo


http://site/_vti_bin/sites.asmx


Special value created to protect again replay attack


SharePoint adds this control through master page


Web service clients need to acquire Form Digest
manually

Demo


Windows Store App


Demo


iOS

App


References


Choose the right API set in SharePoint 2013


How
to: Complete basic operations using SharePoint 2013 client
library code


How to: Complete basic operations using JavaScript library code in
SharePoint
2013


How to: Access SharePoint 2013 data from remote apps using the
cross
-
domain library


Programming using the SharePoint 2013 REST service


How to: Complete basic operations using SharePoint 2013 REST
endpoints


Host webs, app webs, and SharePoint components in SharePoint
2013


Build mobile apps in SharePoint
2013


http
://www.odata.org
/


Questions?