Download - Mobile for SharePoint with Windows Phone
Mobile for SharePoint with Windows Phone
Jim WilcoxEnterprise Software Application Architect
Edgewater Technology
SharePoint
Saturday
Boston
April 12, 2014
Agenda
Introductions
Client “Non-Apps”
SharePoint Web Interfaces
Development Tools / Silverlight Office 365 SharePoint
Demo loading & updating SP List items on Windows Phone
Best Practices
Introductions: Myself
Jim Wilcox Enterprise Software Application Architect
Edgewater Technology (GOLD SPONSOR THIS YEAR!)
Hobbyist Windows Phone App Publisher
Co-Founder of
Granite State (NH) SharePoint Users Group
Granite State (NH) Windows Phone Users Group
Co-Organizer of SharePoint Saturday New Hampshire
Introductions: Session
Survey of ways to create SharePoint-integrated clients on the Windows Phone platform… with a focus on apps Based In Part On
“SharePoint 2010 and Windows Phone 7 Training Course”
http://msdn.microsoft.com/en-us/hh292769
Developer training | Apps for Office and SharePoint
(“MODULE 19: Create Mobile Apps for SharePoint 2013”)
http://msdn.microsoft.com/en-US/office/dn448488
Office 365 Integration
Demos / Code Walkthroughs
Quick Rundown on Client“Non-Apps”
May be helpful to consider tools already in the phone Office Hub / SharePoint Workspaces
Internet Explorer
Desktop Mode
Mobile Mode
Quick Rundown on Client “Non-Apps”
Office Hub / SharePoint Workspaces Pro’s
Readily available, “free”
Con’s
Not so nicely customizable
Quick Rundown on Client“Non-Apps”
Internet Explorer Desktop Mode
Pros
Emulates desktop browser well
Fairly compatible, with lots of common functionality
Cons
Small, tough to navigate
Quick Rundown on Client Non-Apps
Internet Explorer
Mobile Mode
Pros
Still excellent support for compatibility
Improves visibility on small screen
Cons
Limited functionality
Limited User experience
SharePoint Web Interfaces
REST API (ODATA) _api
RSS
Social Web services
Classic SOAP Web Service Interfaces (e.g. lists.asmx)
Client Side Object Model (CSOM)
SharePoint Client App Dev
Challenges (for any client) Authentication
Config
Data Caching
Exception Handling
Windows Phone Challenges Client Side Object Model not supported in WP7
NTLM authentication not available
Silverlight framework “limitations”
everything Async
Silverlight
SILVERLIGHT IS DEAD! LONG LIVE XAML!
WPF like, uses XAML
Stripped down .NET even compared to the .NET Client profile
Async everything
Silverlight
Dev Environment Setting up PHONE Dev Environment
Visual Studio Express 2012 on Windows 8 (Requires Hyper-V for device emulation)
Windows Phone 8 SDK (Installed with Visual Studio 2012 & 2013)
Bing: “Microsoft SharePoint SDK for Windows Phone 8”
http://www.microsoft.com/en-us/download/details.aspx?id=36818
SharePoint 2013 server environment
CSOM has tools to support Windows Phone 8
Async
Communications in Silverlight force Async, multi-threading model.
Building UI’s with XAML UI must be on single thread.
Deploy.Dispatch.BeginInvoke is key to getting back to UI thread
Demo: Walk-thru basic WSS3 app
Visual Studio 2012 Express for Windows Phone
GSSPUG Hub Free App
WSS3 SOAP client
Anonymous Authentication
Office 365 Authentication
Multi-step process (DONE BY CSOM)
Office 365 Authentication (WITHOUT CSOM)
Send credentials to login server
const string _authUrl="https://login.microsoftonline.com/extSTS.srf"; const string _samlXml = @"<s:Envelope xmlns:s=""http://www.w3.org/2003/05/soap-envelope"" xmlns:a=""http://www.w3.org/2005/08/addressing"" xmlns:u=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd""> <s:Header> <a:Action s:mustUnderstand=""1"">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action> <a:ReplyTo> <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> </a:ReplyTo> <a:To s:mustUnderstand=""1"">https://login.microsoftonline.com/extSTS.srf</a:To> <o:Security s:mustUnderstand=""1"" xmlns:o=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd""> <o:UsernameToken> <o:Username>{0}</o:Username> <o:Password>{1}</o:Password> </o:UsernameToken> </o:Security> </s:Header> <s:Body> <t:RequestSecurityToken xmlns:t=""http://schemas.xmlsoap.org/ws/2005/02/trust""> <wsp:AppliesTo xmlns:wsp=""http://schemas.xmlsoap.org/ws/2004/09/policy""> <a:EndpointReference> <a:Address>{2}</a:Address> </a:EndpointReference> </wsp:AppliesTo> <t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType> <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType> <t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType> </t:RequestSecurityToken> </s:Body> </s:Envelope>";
Office 365 Authentication (WITHOUT CSOM)
Get SAML Token from Response<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa="http://www.w3.org/2005/08/addressing"> <S:Header> … </S:Header> <S:Body> <wst:RequestSecurityTokenResponse xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:psf="http://schemas.microsoft.com/Passport/SoapServices/SOAPFault"> <wst:TokenType>urn:passport:compact</wst:TokenType> <wsp:AppliesTo xmlns:wsa="http://www.w3.org/2005/08/addressing"> <wsa:EndpointReference> <wsa:Address>spsnh.sharepoint.com</wsa:Address> </wsa:EndpointReference> </wsp:AppliesTo> <wst:Lifetime> <wsu:Created>2012-09-21T18:17:56Z</wsu:Created> <wsu:Expires>2012-09-22T18:17:56Z</wsu:Expires> </wst:Lifetime> <wst:RequestedSecurityToken> <wsse:BinarySecurityToken Id="Compact0"> t=EwBYAk6hBwAUIQT64YiMbkZQLHdw6peopUrQ0O8AATjrlz3EJAc6fh4IdP8nOlEzhGUzO53lIa7CjgkoTNzz+BQguCDwabOvMsL7u3ygGx8Gm4LLQlOw9CR/UgUDls+fxvLTPRQr7nI3Auw213tJdnXs5PWs4um/78f2aY36j9tauBXoK/O6LIXIDI3KZIIor98P2lhtnWDB8gG1NVEWvhfuMEYDmL07YjkwDVruCbbnn9gERkZUwyPImiR0rV1PlnovxV+nNRNKo09IK4BSFaSBwcBfhDWB4Ai9/3Kw9tL0lw4zhY0KJ0M4rd/YVDeUCjcA5gcL60fQ+gKh0lmYo2koRmzKuDpGjTan/Bo70CoMwh8d4jEqU8MSZliz2y4DZgAACJxQwcoLK56JKAGWzGAu/+QF47YofykIIXHLxmosMINTw7QZ6hdslEEuNQ3+bFaUUZeaP6nihF+XthZwiP5BIodcLhH7BG6XUCL9Wip9pGST1zU0xJ+rXJ2VtTde5kAJDhxp5OoO23VMTMbEmDi+eKaESORzU6j6ijtaGxZsr44ygPa3A/HsFUz+DKBk3EGCvmuMTZOuc3rh8Dd74jNp9ym4TVN+Ge6cvko7XmZJIVIqQQsLcTPt2UXl6UTnLMgiIw1CQXGACTBkkGrNFwswsY0AcUBtFv49ISyhlC0Y39ow0Tl8XL7es/HCVYZTCndEo3FKOBISG+a3Uy+45zqw+sU5X26Aq5UtlnQBUHoHMiO55EeOeByPu58NmpRebekOPQlD4VuVgbl3C/S4Zodp2bCH1WIB&p= </wsse:BinarySecurityToken> </wst:RequestedSecurityToken> … </S:Body></S:Envelope>
Office 365 Authentication (WITHOUT CSOM)
Present SAML token to web service
const string _login="/_forms/default.aspx?wa=wsignin1.0"; private void SubmitTokenAsync() {
UriBuilder bldr = new UriBuilder(_uri.Scheme, _uri.Host, _uri.Port); _submitTokenRequest = HttpWebRequest.CreateHttp(bldr.Uri + _login); _submitTokenRequest.CookieContainer = Cookies; _submitTokenRequest.Method = "POST"; _submitTokenRequest.BeginGetRequestStream(new AsyncCallback(Get_SubmitToken_RequestStreamCallback), null); }
private void Get_SubmitToken_RequestStreamCallback(IAsyncResult result) { var requestStream = _submitTokenRequest.EndGetRequestStream(result); using (StreamWriter w = new StreamWriter(requestStream)) { w.Write(_token); w.Flush(); } _submitTokenRequest.BeginGetResponse(new AsyncCallback(Get_SubmitToken_ResponseCallback), null); }
Office 365 Authentication (WITHOUT CSOM)
Include cookie in GetListItems service call.
private void Get_SubmitToken_ResponseCallback(IAsyncResult result) { UriBuilder bldr = new UriBuilder(_uri.Scheme, _uri.Host, _uri.Port); bldr.Path = null; Cookies = _submitTokenRequest.CookieContainer; _isAuthenticationInProgress = false; IsAuthenticated = true; if (OnAuthenticated != null) { EventArgs args = new EventArgs(); OnAuthenticated(this, args); //Call back the parent } }
----------------- parent
_listsClient = new ListsSoapClient();
void OnAuthenticated_GetTasks(object sender, EventArgs e) { _authenticationHelper = (SPAuthenticationHelper)sender; _listsClient.CookieContainer = _authenticationHelper.Cookies; BeginGetTasksList(); }
Windows Phone 8 / SharePoint 2013
MS Training video was outdated…
….VS 2012, not 2010
…. WP8 not WP7
…. Office 365
“List” apps
CSOM
Push notifications
DEMO: “List” App
CSOM
Variant of CSOM used by SharePoint 2010
To say authentication is simplified…
public class ListDataProvider : ListDataProviderBase { /// <summary> /// Provides access to ClientContext object which is used to execute queries to fetch ListItems from SharePoint server /// </summary> private ClientContext m_Context; public override ClientContext Context { get { if (m_Context != null) return m_Context;
m_Context = new ClientContext(SiteUrl);
Authenticator at = new Authenticator(); at.CookieCachingEnabled = true; //Allows authenticator to save cookies for future usage // In case of Microsoft Online federated authentication, set ADFS authentication scheme preference for passive authentication // Example, to set client preference for SAML 2.0 username-password authentication scheme: // at.FederationPassiveAuthUri = "urn:oasis:names:tc:SAML:2.0:ac:classes:Password"; m_Context.Credentials = at;
return m_Context; } }
Push Notifications
Device requests URI from PNS
Device registers URI with SharePoint App
SharePoint app is implemented to send notification via PNS to URI,
which in turn pings the phone.
Push Notification Types
Toast Appears at top of UI inside or outside of app
Tile Updates live tile info
Raw Notification event raised to app, which
implements its own handler (app must be running)
Alternative: App Studio
Into
Demo
Best Practices
Isolated Storage / Offline Mode
Proper Exception Handling
Proper Logging
Proper Configuration
Security / Encryption
Be Bandwidth Aware (compression, caching where possible)
Be Memory Aware
More Best Practices
Unit Testing
UI Lipstick
App Publishing
Additional Technologies
Lightswitch
HTML5 / JS
Xamarin
Questions?
Thank You
For taking personal time to make this presentation and event a part of your professional portfolio
Feel free to connect with me on:
Facebook: http://www.facebook.com/jwilcox1701
LinkedIn: http://www.linkedin.com/in/jimwilcox2
Twitter: @GraniteStHacker
Blog: http://GraniteStateHacker.kataire.com
Granite State (NH) SharePoint Users Group: http://www.granitestatesharepoint.com
Granite State (NH) Windows Phone Users Group: http://granitestatewinphone.Eventbrite.com
Yammer, Foursquare, Klout….