First steps with Capacitor… in the real world

A presentation at Codeurs en Seine in November 2018 in Rouen, France by Horacio Gonzalez

Slide 1

Slide 1

First steps with Capacitor… in the real world Horacio Gonzalez @LostInBrittany #capacitor @LostInBrittany

Slide 2

Slide 2

Who am I? Introducing myself and introducing OVH #capacitor @LostInBrittany

Slide 3

Slide 3

Horacio Gonzalez @LostInBrittany Spaniard lost in Brittany, developer, dreamer and all-around geek #capacitor @LostInBrittany

Slide 4

Slide 4

OVH : Key Figures 1.3M Customers worldwide in 138 Countries 1.5 Billions euros investment over five years 30 Datacenters (growing) 350k Dedicated Servers 200k Private cloud VMs running 650k Public cloud Instances created in a month 15TB bandwidth capacity

  • 2 500 Employees in 19 countries 18 Years of Innovation 35 Points of presence 4TB Anti DDoS capacity Hosting capacity : 1.3M Physical Servers #capacitor @LostInBrittany

Slide 5

Slide 5

OVH: A Global Leader on Cloud 200k Private cloud VMs running 1 Dedicated IaaS Europe 2018 27 Datacenters Own 15 Tbps Hosting capacity : 1.3M Physical Servers 360k Servers already deployed 2020 50 Datacenters Netwok with 35 PoPs

1.3M Customers in 138 Countries #capacitor @LostInBrittany

Slide 6

Slide 6

OVH: Our solutions Cloud Web Hosting Mobile Hosting Telecom VPS Containers ▪ Dedicated Server Domain names VoIP Public Cloud Compute ▪ Data Storage Email SMS/Fax Private Cloud ▪ Network and Database CDN Virtual desktop Serveur dédié Security Object Storage Web hosting Cloud HubiC Over theBox ▪ Licences Cloud Desktop Securities MS Office Hybrid Cloud Messaging MS solutions #capacitor @LostInBrittany

Slide 7

Slide 7

Capacitor The Native Bridge for Cross-Platform Web Apps #capacitor @LostInBrittany

Slide 8

Slide 8

What's Capacitor? Cross-platform app runtime making it easy to build web apps that run natively on iOS, Android and web #capacitor @LostInBrittany

Slide 9

Slide 9

Spiritual heir to Apache Cordova Evolution, not revolution #capacitor @LostInBrittany

Slide 10

Slide 10

Spiritual heir to Apache Cordova Support for many Cordova plugins #capacitor @LostInBrittany

Slide 11

Slide 11

Extensible and evolutif ● Close to web-standards ● Plugin API ○ Swift on iOS ○ Java on Android ○ JavaScript for the web #capacitor @LostInBrittany

Slide 12

Slide 12

Developer Friendly Easy to get started Works on any framework #capacitor @LostInBrittany

Slide 13

Slide 13

You still need the platform tools Android Studio and/or Xcode to build the native packages #capacitor @LostInBrittany

Slide 14

Slide 14

Weren't you a PWA advocate? And you are also championing Flutter! Where is the coherence, guy? #capacitor @LostInBrittany

Slide 15

Slide 15

Well, I am a PWA advocate indeed I rooted for PWA before it was fancy... #capacitor @LostInBrittany

Slide 16

Slide 16

And I know the numbers... Apps drive engagement, web drive visitors... 20 biggest apps account for 80% of user time #capacitor @LostInBrittany

Slide 17

Slide 17

An engineer role is to choose The right tool for the right problem #capacitor @LostInBrittany

Slide 18

Slide 18

If you need super fancy UX 60 FPS, slick animations, an experience more than an app Then go full native And BTW, do it in Flutter believe me, you will thank me! #capacitor @LostInBrittany

Slide 19

Slide 19

For more normal needs A well done PWA is simply enough #capacitor @LostInBrittany

Slide 20

Slide 20

But if you need to be in the store? For many reasons, not all objective... #capacitor @LostInBrittany

Slide 21

Slide 21

Hybrid PWA apps The best of two worlds #capacitor @LostInBrittany

Slide 22

Slide 22

Capacitor take your PWA to the store In a simple, quick and painless way #capacitor @LostInBrittany

Slide 23

Slide 23

First steps testing Capacitor Adding Capacitor to an existing app #capacitor @LostInBrittany

Slide 24

Slide 24

From web to native Giving superpowers to you webapp #capacitor @LostInBrittany

Slide 25

Slide 25

Testing with a real webapp Warp 10 Photon - IDE for Warp 10 #capacitor @LostInBrittany

Slide 26

Slide 26

Step 1 - Add Capacitor to the app Install Capacitor cd my-app npm install --save @capacitor/core @capacitor/cli Init Capacitor npx cap init Add Android and/or iOS and/or Electron support npx cap add android #capacitor @LostInBrittany

Slide 27

Slide 27

Step 2 - Copy to Android Edit capacitor.config.json Copy the built resources to Android npx cap copy Launch Android Studio and navigate to the project #capacitor @LostInBrittany

Slide 28

Slide 28

Step 3 - Test And our webapp is now a native app #capacitor @LostInBrittany

Slide 29

Slide 29

First test: successful! Capacitor 1 - Scepticism 0 #capacitor @LostInBrittany

Slide 30

Slide 30

The Capacitor example app Nice to explore Capacitor #capacitor @LostInBrittany

Slide 31

Slide 31

Made by the Ionic team To replace Cordova in next Ionic #capacitor @LostInBrittany

Slide 32

Slide 32

Official example built on Ionic Showcasing the upcoming Ionic 4 #capacitor @LostInBrittany

Slide 33

Slide 33

Let's try the official example #capacitor @LostInBrittany

Slide 34

Slide 34

Using directly the Capacitor repository Custom built project, not a production app ● @capacitor/core and native libs loaded from local directory #capacitor @LostInBrittany

Slide 35

Slide 35

Let's build the Android version Some pre-building and building needed... #capacitor @LostInBrittany

Slide 36

Slide 36

We now have an Android project #capacitor @LostInBrittany

Slide 37

Slide 37

Easy and painless Android app #capacitor @LostInBrittany

Slide 38

Slide 38

And in PWA mode? Some elements haven't web implementation (yet?) #capacitor @LostInBrittany

Slide 39

Slide 39

But it still works! It fails gracefully for unsupported plugins #capacitor @LostInBrittany

Slide 40

Slide 40

Second test: successful! Capacitor 2 - Scepticism 0 #capacitor @LostInBrittany

Slide 41

Slide 41

Let's try something harder #capacitor @LostInBrittany

Slide 42

Slide 42

Capacitor without Ionic I want to use it Capacitor with my own toolset #capacitor @LostInBrittany

Slide 43

Slide 43

I'm a Web Components guy And I speak a lot about Polymer #capacitor @LostInBrittany

Slide 44

Slide 44

But Polymer is in a transition phase Polymer 2.x : bower based Polymer 3: npm based #capacitor @LostInBrittany

Slide 45

Slide 45

So what to use? Stencil, of course! The magical, reusable web component compiler #capacitor @LostInBrittany

Slide 46

Slide 46

Let's begin with a simple example A Camera app, working well on web mode Using standard Media Capture and Streams API #capacitor @LostInBrittany

Slide 47

Slide 47

Let's charge it with Capacitor We want the same behavior But now in Android, iOS, Electron AND web #capacitor @LostInBrittany

Slide 48

Slide 48

And does it work? Yes it does… in native mode only! #capacitor @LostInBrittany

Slide 49

Slide 49

But not in PWA mode :( And a big question: why? #capacitor @LostInBrittany

Slide 50

Slide 50

Well, let's spot the differences... Searching on the example code hmmmm, @ionic/pwa-elements, what's that? #capacitor @LostInBrittany

Slide 51

Slide 51

@ionic/pwa-elements Web-based alternatives for some Capacitor plugins #capacitor @LostInBrittany

Slide 52

Slide 52

Adding @ionic/pwa-elements Simply install them: npm install @ionic/pwa-elements And then import them: import '@ionic/pwa-elements'; #capacitor @LostInBrittany

Slide 53

Slide 53

And then... It's a kind of magic! #capacitor @LostInBrittany

Slide 54

Slide 54

On Android and Web #capacitor @LostInBrittany

Slide 55

Slide 55

Second test: successful! Capacitor 3 - Scepticism 0 #capacitor @LostInBrittany

Slide 56

Slide 56

And in Real Life? Because examples are examples... #capacitor @LostInBrittany

Slide 57

Slide 57

Use case 1: Putting PWA into store It simply works, easy and painless! #capacitor @LostInBrittany

Slide 58

Slide 58

Use case 2: Progressive enhancing Giving your PWA an extra P when going native #capacitor @LostInBrittany

Slide 59

Slide 59

And Capacitor already works A true winner #capacitor @LostInBrittany

Slide 60

Slide 60

Conclusions Capacitor or not? #capacitor @LostInBrittany

Slide 61

Slide 61

Paint is still wet Some things are broken Some things will change #capacitor @LostInBrittany

Slide 62

Slide 62

Easy to use Friendlier than Cordova #capacitor @LostInBrittany

Slide 63

Slide 63

Yet extensible You can use existing Cordova plugins #capacitor @LostInBrittany

Slide 64

Slide 64

Not opinionated Easy to use in any framework Easy to integrate in any dev toolchain #capacitor @LostInBrittany

Slide 65

Slide 65

Thank you! #capacitor @LostInBrittany