adaptto() 2014 - mobile app dev with cordova, sling, and aem

35
APACHE SLING & FRIENDS TECH MEETUP BERLIN, 22-24 SEPTEMBER 2014 Mobile app development with Apache Cordova and AEM Bruce Lefebvre, Adobe

Upload: rbl002

Post on 11-Jun-2015

322 views

Category:

Software


0 download

DESCRIPTION

From http://adapt.to/2014/en/schedule/mobile-app-development-with-apache-cordova-and-aem.html: This talk will focus on patterns and tools for bringing your Sling and web expertise to the world of mobile applications. Centre stage will be Cordova, an Apache project with PhoneGap origins - built to enable cross-platform mobile apps and in turn, advance the open web. I'll introduce techniques for solving common use cases with Sling as the backend, complete with sample code to get you started today. Lastly, we'll take a look at the integration of Cordova and AEM (affectionately known as PhoneGap Enterprise) featured in the 6.0 release.

TRANSCRIPT

Page 1: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

APACHE SLING & FRIENDS TECH MEETUP BERLIN, 22-24 SEPTEMBER 2014

Mobile app development with Apache Cordova and AEM Bruce Lefebvre, Adobe

Page 2: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

adaptTo() 2014 2

Hello

@brucelefebvre  

Page 3: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

adaptTo() 2014 3

<%          out.println("<h1>                  AGENDA                        </h1>"  +                                  "<ul>                                                                "  +                                  "    <li>                  Problem?                </li>"  +                                  "    <li>                  Solution                          "  +                                  "        <ul>                                                        "  +                                  "            <li>              Cordova              </li>"  +                                  "            <li>              +  Sling              </li>"  +                                  "            <li>              +  AEM                  </li>"  +                                  "        </ul>                                                      "  +                                  "    </li>                                                          "  +                                  "</ul>                                                              ");  %>  

agenda.jsp

Page 4: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

4

Problem?

Page 5: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

adaptTo() 2014 5

Java            C#,  C++  

Objec3ve-­‐C            Java  

2014

Page 6: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

adaptTo() 2014 6

?????            

2016

Page 7: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

adaptTo() 2014 7

Goal: Avoid proprietary vendor traps

Page 8: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

adaptTo() 2014 8

The Open Web

§  Opinion: The web solved crossed platform §  Open & standardized (for the most part)

Page 9: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

adaptTo() 2014 9

Goal: Presence in app store(s)

Page 10: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

adaptTo() 2014 10

Enter Hybrid Applications

§  Web app wrapped in a device native shell §  Write once, run everywhere*

§  *aka “the promised land”

Na3ve  SDKs  

Page 11: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

adaptTo() 2014 11

But… Web vs. Native!

§  Both built on the same set of technologies §  Web capabilities sufficient for most apps

“If a browser doesn’t do something its not because it can’t;

it’s just because we haven’t gotten around to implementing that part yet.” -Brian LeRoux

Page 12: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

But the web can’t…

adaptTo() 2014 12

§  Access device features, like: §  Camera §  Device motion §  File system §  Location

§  Provide background notifications §  Render without connectivity

§  or even poor connectivity

§  Or can it?

Page 13: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Enter Apache Cordova

adaptTo() 2014 13

Build apps with web tech you know and love

Page 14: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Cordova

adaptTo() 2014 14

§  A cross-platform app framework §  Initially PhoneGap, created by Nitobi

§  Donated to ASF in 2011 as Cordova §  of which PhoneGap is a distribution

Page 15: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Cordova

adaptTo() 2014 15

§  Supported platforms §  iOS

§  Android §  BB10

§  WP7, WP8, Windows 8

§  Amazon Fire OS §  Tizen

§  and more…

Page 16: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Cordova Plugins

adaptTo() 2014 16

§  Device APIs: §  Camera  §  Geoloca3on  §  Accelerometer  §  File  §  Contacts  §  Events  §  Connec3on  §  No3fica3on  §  Storage  §  InAppBrowser  §  Device  §  Compass  §  Globaliza3on  

Page 17: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Cordova CLI

adaptTo() 2014 17

§  Command line interface features §  Bootstrap a new app

§  build/install/run app on a specific platform §  Locally  or  via  PhoneGap  build  

§  Manage plugins

Page 18: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

adaptTo() 2014 18

Let’s give it a try

Page 19: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Cordova CLI at a glance

adaptTo() 2014 19

§  Create your app: cordova create helloAdaptTo

§  Add a platform: cd helloAdaptTo

cordova platform add ios

§  Run your app on a simulator:

cordova emulate ios

Page 20: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Cordova + Sling

adaptTo() 2014 20

§  Goals: §  Repurpose existing content §  Fetch & present data with

minimum server side customization

§  Authenticate with the server

Page 21: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Cordova + Sling

adaptTo() 2014 21

§  Bonus goals §  Post content from device §  Be indistinguishable from

a native app §  Offline access to content

Page 22: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

adaptTo() 2014 22

Less talk, more action

bit.ly/blog-­‐app  

Page 23: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Goal: Repurpose existing content

adaptTo() 2014 23

§  server/espblog/[…]/apps/espblog/json.esp {

"title": "<%=post.title%>",

"link": "<%= serverURI %><%=post%>.json",

"description": "<%=post.posttext%>",

"pubDate": "<%=df.format(post.created.getTime())%>",

"resources": {

"attachments": [

<% renderMedia(post, "attachments"); %>

]

}

}

Page 24: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Goal: Fetch & present data

adaptTo() 2014 24

§  www/js/controllers.js

$http.get(slingHostURI + '/content/espblog/posts.list.json') .success(function(data, status) {

$scope.connected = true;

$scope.blogPostList = data.posts;

}) .error(function(data, status) {

$scope.connected = false;

console.error('Blog post list fetch failed’);

});

Page 25: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Goal: Authenticate with the server

adaptTo() 2014 25

§  www/js/controllers.js $http({

method: 'POST',

url: slingHostURI + '/j_security_check', data: formData,

headers: {

'Content-Type': undefined

},

transformRequest: formDataObject

})

basicAuthentication.setCredentials(formData.j_username, formData.j_password);

Page 26: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Cordova + Sling

adaptTo() 2014 26

§  Reuse existing content §  Reuse existing infra §  Reuse existing web skills §  Write once, run cross-

platform

Page 27: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Cordova + AEM --- PhoneGap Enterprise

adaptTo() 2014 27

Page 28: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

PhoneGap Enterprise

adaptTo() 2014 28

§  Highlights §  Update app content w/o writing code §  Integration with Adobe Mobile Services

§  Over the Air content updates §  AngularJS integration §  Geometrixx reference implementation

Page 29: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

PhoneGap Enterprise

adaptTo() 2014 29

Page 30: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

adaptTo() 2014 30

PhoneGap Enterprise demo

bit.ly/aem-­‐pg  

Page 31: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Recap

adaptTo() 2014 31

§  Problem? §  Solution

§  Cordova §  + Sling

§  + AEM

Page 32: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

adaptTo() 2014 32

Questions?

@brucelefebvre  

bit.ly/blog-­‐app   bit.ly/aem-­‐pg  

Page 33: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

adaptTo() 2014 33

Appendix

Page 34: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Resources

adaptTo() 2014 34

§  Cordova + Sling blog app Github repository §  PhoneGap Kitchen Sink Github repository §  PhoneGap Beliefs, Goals, and Philosophy – Brian LeRoux §  PhoneGap, Cordova, and what’s in a name? – Brian LeRoux §  PhoneGap Documentation – v. 3.5.0

Page 35: adaptTo() 2014 - Mobile app dev with Cordova, Sling, and AEM

Creative Resources

adaptTo() 2014 35

§  ‘But the web can’t’ slide http://www.designcaffeine.com/uncategorized/mobile-magic-moments-transform-the-trivial/

§  ‘Cordova CLI’ slide http://www.stradiji.com/wp-content/uploads/2013/03/swiss-army-knife.png

§  ‘Cordova Plugins’ slide http://www.freshtilledsoil.com/native-app-vs-mobile-website/

§  Apache httpd http://httpd.apache.org/ §  ECMA logo http://en.wikipedia.org/wiki/Ecma_International

§  W3C http://www.w3.org/

§  WHATWG http://www.whatwg.org/

§  AngularJS https://angularjs.org/

§  Sling http://sling.apache.org/

§  HTML http://en.wikipedia.org/wiki/HTML