Polymer 2 and Cordova
Asked Answered
Z

1

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>
Zebe answered 8/6, 2017 at 9:38 Comment(8)
keep in mind that cordova doesn't use Safari but UIWebView. Do not expect the same functionality when testing things on Safari.Mellifluous
can you provide a full sample?Willable
@Zebe i m not an expert in polymer. But dont you need to have this HTML import to import polymer library - <link rel="import" href="../polymer/polymer-element.html"> Check out this link - polymer-project.org/2.0/start/first-element/step-2Clancy
@Zebe any update on this?Clancy
@Willable here's the full sample drive.google.com/open?id=0B9oPYAW5j_fDRy1sZW1YLWJXV00Zebe
@akis do i need addition steps in order for it to work? THanksZebe
@Clancy tried your suggestion but still doesn't work.Zebe
@Zebe 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.Mellifluous
W
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.

Willable answered 20/6, 2017 at 11:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.