Hi @celebvoice,
I think the problem is, that the PWA does not know there is a native app (or TWA) that os related to itself.
You coud use the web_app_manifest
filter (https://github.com/SayHelloGmbH/progressive-wordpress/blob/master/Classes/class-manifest.php#L154) to add the related_applications
and the prefer_related_applications
property to your web app manifest:
https://developer.mozilla.org/en-US/docs/Web/Manifest/related_applications
https://developers.google.com/web/fundamentals/app-install-banners/native
I’m quite sure this will solve your problem.
Hello @nico_martin
Thanks for the response,
"related_applications": [
{
"platform": "play",
"url": "https://play.google.com/store/apps/details?id=com.example.app1",
"id": "com.example.app1"
}, {
"platform": "itunes",
"url": "https://itunes.apple.com/app/example-app1/id123456789"
}
]
How can I add this code to be generated in manifest?
I would like to add via functions.php so that the code doesn’t loose when I updated plugin.
can i use like this?
function web_app_manifest()
{
$related_applications = {
"platform": "play",
"url": "https://play.google.com/store/apps/details?id=com.example.app1",
"id": "com.example.app1"
}, {
"platform": "itunes",
"url": "https://itunes.apple.com/app/example-app1/id123456789"
};
apply_filters( 'web_app_manifes', $related_applications )
);
}
-
This reply was modified 3 years, 5 months ago by celebvoice.
-
This reply was modified 3 years, 5 months ago by celebvoice.
Hi @celebvoice
You could use it like this:
add_filter('web_app_manifest', function ($vars) {
$vars['related_applications'] = [
[
"platform" => "play",
"url" => "https://play.google.com/store/apps/details?id=com.example.app1",
"id" => "com.example.app1"
],
[
"platform" => "itunes",
"url" => "https://itunes.apple.com/app/example-app1/id123456789"
]
];
return $vars;
});
-
This reply was modified 3 years, 5 months ago by Nico Martin.
hello @nico_martin
the code worked like wonder.
I have also added prefer_related_applications
Thanks For The Great Support
/* add Related apps to web app manifest */
add_filter('web_app_manifest', function ($vars) {
$vars['prefer_related_applications'] = true;
return $vars;
});
add_filter('web_app_manifest', function ($vars) {
$vars['related_applications'] = [
[
"platform" => "play",
"url" => "https://play.google.com/store/apps/details?id=com.example.app",
"id" => "com.example.app"
]
];
Love the code @celebvoice–this fixes my issue too. Just one adjustment to the syntax:
/* PWA/TWA compatibility */
add_filter('web_app_manifest', function ($vars) {
$vars['prefer_related_applications'] = true;
return $vars;
});
add_filter('web_app_manifest', function ($vars) {
$vars['related_applications'] = [
[
"platform" => "play",
"url" => "https://play.google.com/store/apps/details?id=com.sushihelado.twa",
"id" => "com.sushihelado.twa"
]
];
});