7

I'm trying to create a hybrid app using Polymer 2.0. I've used polymer-2-application and polymer-2-starter-kit sample and it was working when it is tested on safari browser.

Safari browser

But when I run it on iOS simulator the Polymer element did not display.

enter image description here

Here's my sample index.html

<!DOCTYPE html>
<html>
    <head>
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <meta name="description" content="TestPolymer-2 description">

        <link rel="manifest" href="/manifest.json">

        <script src="bower_components/webcomponentsjs/webcomponents-loader.js"></script>

        <link rel="import" href="src/test-element/test-element.html">

        <title>Hello World</title>
    </head>
    <body>
        <div class="app">
            <test-element></test-element>
            <h1>Apache Cordova</h1>
            <div id="deviceready" class="blink">
                <p class="event listening">Connecting to Device</p>
                <p class="event received">Device is Ready</p>
            </div>
        </div>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
    </body>
</html>
marvz
  • 369
  • 2
  • 7
  • 1
    keep in mind that cordova doesn't use Safari but UIWebView. Do not expect the same functionality when testing things on Safari. – Sarantis Tofas Jun 14 '17 at 17:48
  • 1
    can you provide a full sample? – jcesarmobile Jun 14 '17 at 23:02
  • @marvz i m not an expert in polymer. But dont you need to have this HTML import to import polymer library - Check out this link - https://www.polymer-project.org/2.0/start/first-element/step-2 – Gandhi Jun 15 '17 at 18:38
  • @marvz any update on this? – Gandhi Jun 17 '17 at 18:43
  • @jcesarmobile here's the full sample https://drive.google.com/open?id=0B9oPYAW5j_fDRy1sZW1YLWJXV00 – marvz Jun 20 '17 at 10:06
  • @akis do i need addition steps in order for it to work? THanks – marvz Jun 20 '17 at 10:08
  • @Gandhi tried your suggestion but still doesn't work. – marvz Jun 20 '17 at 10:09
  • @marvz i dont have any experience on what you are looking for but i just wanted to make sure that you are searching in the correct direction. A lot of people think that cordova runs safari, but its not, you can search for more info. – Sarantis Tofas Jun 20 '17 at 20:33

1 Answers1

2

The problem is the Polymer 2 HTML Imports don't work on iOS < 10.3. To make it work you need a Polyfill.

See the Polymer 2 support chart.

Also, Polymer 2 uses ES6, which is only supported on iOS 10+, to use it on iOS 9 you have to compile your application to ES5.

But with iOS 10 having 86%, I would recommend to just ditch iOS 9 and only support iOS 10 in your app.

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176