javascript - getInstalledRelatedApps() API not detecting the installed app - Stack Overflow

I've been trying to implement the getInstalledRelatedApps API to work into my project in a smartba

I've been trying to implement the getInstalledRelatedApps API to work into my project in a smartbanner using jquery.smartbanner.js, but the relatedApps const as shown below is returning empty, and the state of the promise is always in "pending". A screenshot of the promise is attached below:

   (async function () {
        alert("running");
        const relatedApps = await navigator.getInstalledRelatedApps();
        alert(relatedApps);
        console.log(relatedApps);
        relatedApps.forEach((app) => {
            console.log(app.id, app.platform, app.url);
        });
        })();

The manifest.json is as:

{ 
    "name": "Example", 
    "short_name": "Example", 
    "lang": "en-US", 
    "theme_color": "#192c4f", 
    "background_color": "#192c4f", 
    "display": "standalone", 
    "scope": "/", 
    "start_url": "/", 
    "icons": [
    { 
        "src": "images/36.png",
        "sizes": "36x36",
        "type": "image/png" 
    },
    { 
        "src": "images/48.png",
        "sizes": "48x48",
        "type": "image/png" 
    },
    { 
        "src": "images/72.png",
        "sizes": "72x72",
        "type": "image/png" 
    },
    { 
        "src": "images/96.png",
        "sizes": "96x96",
        "type": "image/png" 
    },
    { 
        "src": "images/144.png",
        "sizes": "144x144",
        "type": "image/png" 
    },
    { 
        "src": "images/192.png",
        "sizes": "192x192",
        "type": "image/png" 
    }
],
    "splash_pages": null,
    "prefer_related_applications": true,
    "related_applications": [{
            "platform": "play",
            "id": ".example.android"
           
    }]
}

The playstore app ID has been doublechecked from the android app side. any help would be appreciated, thanks!

I've been trying to implement the getInstalledRelatedApps API to work into my project in a smartbanner using jquery.smartbanner.js, but the relatedApps const as shown below is returning empty, and the state of the promise is always in "pending". A screenshot of the promise is attached below:

   (async function () {
        alert("running");
        const relatedApps = await navigator.getInstalledRelatedApps();
        alert(relatedApps);
        console.log(relatedApps);
        relatedApps.forEach((app) => {
            console.log(app.id, app.platform, app.url);
        });
        })();

The manifest.json is as:

{ 
    "name": "Example", 
    "short_name": "Example", 
    "lang": "en-US", 
    "theme_color": "#192c4f", 
    "background_color": "#192c4f", 
    "display": "standalone", 
    "scope": "/", 
    "start_url": "/", 
    "icons": [
    { 
        "src": "images/36.png",
        "sizes": "36x36",
        "type": "image/png" 
    },
    { 
        "src": "images/48.png",
        "sizes": "48x48",
        "type": "image/png" 
    },
    { 
        "src": "images/72.png",
        "sizes": "72x72",
        "type": "image/png" 
    },
    { 
        "src": "images/96.png",
        "sizes": "96x96",
        "type": "image/png" 
    },
    { 
        "src": "images/144.png",
        "sizes": "144x144",
        "type": "image/png" 
    },
    { 
        "src": "images/192.png",
        "sizes": "192x192",
        "type": "image/png" 
    }
],
    "splash_pages": null,
    "prefer_related_applications": true,
    "related_applications": [{
            "platform": "play",
            "id": ".example.android"
           
    }]
}

The playstore app ID has been doublechecked from the android app side. any help would be appreciated, thanks!

Share Improve this question asked Mar 26, 2021 at 11:52 Zaeem HabibZaeem Habib 951 silver badge7 bronze badges 3
  • Did you follow all of the steps in: Check if your Android app is installed – Morrison Chang Commented Mar 26, 2021 at 12:09
  • Yep, all the steps followed, everything's done just as the tutorial suggested. – Zaeem Habib Commented Mar 26, 2021 at 13:08
  • 1 Facing the same issue, any solution? – Himanshu Commented Apr 22, 2023 at 14:33
Add a ment  | 

1 Answer 1

Reset to default 2

Change related application object

1- the platform must be "webapp" in the case of PWA

2- url is the full path to the web app manifest of your PWA

"related_applications": [{ "platform": "webapp", "url": "https://example./manifest.json", }]

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745334851a4623055.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信