Search code examples
phpfacebookionic-frameworkcustom-scheme-url

facebook opening hybrid app in their webview


I am working on developing mobile in ionic framework, and i am using custom scheme url for app.

Feature i am working:

When user share anything on facebook, and when other user click on that facebook shared link they will redirected to that shared content details page inside of app if they have installed app otherwise it will redirect to apple or google play store.

Issue:

When user click on that shared link on facebook, app is opened in facebook webview rather than opening app itself.

Does anyone came across such issues? Or am i doing something wrong with this?

Platforms:

  • Ionic Framework for app
  • PHP for backend.

PHP code for redirect user to app:

header("Location: MYAPP://eventpage/eventID");

Solution

  • After looking into AndroidManifest.xml of my app, I found the following preference:

    <activity android:name="MainActivity" android:launchMode="singleTop"
    

    And i read Android Document and found below lines there.

    As shown in the table below, the modes fall into two main groups, with "standard" and "singleTop" activities on one side, and "singleTask" and "singleInstance" activities on the other. An activity with the "standard" or "singleTop" launch mode can be instantiated multiple times.

    So i changed my Manifest as below and its working fine.

    <activity android:name="MainActivity" android:launchMode="singleInstance"
                                                             ^^^^^^^^^^^^^^^^