• Hello,
    If one clicks on add to home screen , it add and doesn’t show the request next time.

    This works fine

    But I have built TWA over pwa using pwabuilder. Now when a user install TWA, and visits site add to home screen still appear.

    PWA is unable to recognise TWA.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Nico Martin

    (@nico_martin)

    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.

    Thread Starter celebvoice

    (@celebvoice)

    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.

    Thread Starter celebvoice

    (@celebvoice)

    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, 6 months ago by celebvoice.
    • This reply was modified 3 years, 6 months ago by celebvoice.
    Plugin Author Nico Martin

    (@nico_martin)

    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, 6 months ago by Nico Martin.
    Thread Starter celebvoice

    (@celebvoice)

    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"
    		]
    	];
    });
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Pwa doesn’t recognise TWA’ is closed to new replies.