GithubHelp home page GithubHelp logo

Comments (8)

LukasSarnowskiC9 avatar LukasSarnowskiC9 commented on July 17, 2024 1

I have the same problem as vlasovilya and my service worker code looks the same as his. Everything is working fine when the app runs as PWA but not as TWA.

from svgomg-twa.

andreban avatar andreban commented on July 17, 2024 1

re: the issue with Pixel and Chrome 74 / 75, could you please test on Chrome Canary? An issue with bringing the application to foreground was fixed and is available there.

from svgomg-twa.

kolyuchii avatar kolyuchii commented on July 17, 2024 1

Hello @vlasovilya and @LukasSarnowskiC9,
I've faced the same issue but it still doesn't work for me.

self.addEventListener('notificationclick', function(event) {
        function sendMsg(client, url, notification) {
            client.postMessage(self.JSON.stringify({ url, notification }));
        }

        function openUrl(openingUrl) {
            return self.clients.openWindow(openingUrl);
        }
        event.notification.close();

        const data = event.notification.data;
        const url = data.url;
        const notification = data.notification;

        event.waitUntil(
            self.clients
                .matchAll({ type: 'window', includeUncontrolled: true })
                .then(function(clientList) {
                    const nonNested = clientList.filter(client => client.frameType !== 'nested');

                    // if there are no non-framed clients, just open the new window with the specified url
                    if (nonNested.length === 0) {
                        return openUrl(url);
                    } else {
                        for (let i = 0; i < clientList.length; i++) {
                            const firstClient = nonNested[i];

                            if ('focus' in firstClient) {
                                return firstClient
                                    .focus()
                                    .then(sendMsg.bind(null, firstClient, url, notification))
                                    .catch(openUrl.bind(null, url));
                            }
                        }
                    }
                })
        );
    });

Could you please share your piece of code which is working on Canary?

from svgomg-twa.

andreban avatar andreban commented on July 17, 2024

Can you provide more information on the browser version, device model and Android version? Also, can you take a look on #15 and point if that is a similar issue?

from svgomg-twa.

LukasSarnowskiC9 avatar LukasSarnowskiC9 commented on July 17, 2024

I have tested this on Android Studio Emulator (Chrome 74 and 75 on android 7.0 and 8.0), on Pixel XL (Android 8.0, Chrome 74 and 75) and on Huawei (Android 8.0, Chrome 74). On the Pixel devices the clients.openWindow(url) is ignored when the app is in background (not waking up the app) and on Huawai the app just closes/crashes when in background/foreground (it only opens the app when it is completely closed). When i run the page as PWA the clients.openWindow(url) brings the app to the foreground as expected.

from svgomg-twa.

LukasSarnowskiC9 avatar LukasSarnowskiC9 commented on July 17, 2024

Thank you for the information andreban. I have now tested my TWA with the canary Chrome version and it is working as intended.

from svgomg-twa.

vlasovilya avatar vlasovilya commented on July 17, 2024

Thanks @andreban and @LukasSarnowskiC9, it helped. Let's wait new Chrome version released then.

from svgomg-twa.

ManalLiaquat avatar ManalLiaquat commented on July 17, 2024

@LukasSarnowskiC9 Can you please tell me how did you test your TWA in chrome canary? Because TWA always opens in default chrome browser. How did you specify to open in canary instead of chrome? Or did you mean PWA, not TWA?

from svgomg-twa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.