Need A Intent-Filter that runs my app when I click on a Buttom in Main Website

Issue

OK. Here is my scenario:

  1. Somehow I open A Payment Gateway from my Android App. (So far So good!)

Payment Gateway > Android App

  1. Then Depending on how payment interactions turns out for user (whether he pays or cancels) There must be two buttons:

ACCEPT—————————–CANCEL

  1. When User Clicks on Cancel I want him to return to app with a message like (FAILED)

  2. When User Clicks on Accept I want him to return to app with a message like (DONE)

So Based On The message I will Show him a page in my app notifying him with more info.

I Know How to Open My app using <Intent-Filter> But I want it more Specified!
I Know this That I need a referral link to put it in my <a href=''> </a> tag This Link must specify my package name and the activity I’m about to do.

Thank You in advance 🙂

Solution

You can use uni_links plugin to deep linking and app linking in flutter :

add this to activity tag in manifest:

  <!-- Deep Links -->
  <intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST -->
    <data
      android:scheme="[YOUR_SCHEME]"
      android:host="[YOUR_HOST]" />
  </intent-filter>

then in dart side

  Future<void> initUniLinks() async {
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      final initialLink = await getInitialLink();
      // Parse the link and warn the user, if it is not correct,
      // but keep in mind it could be `null`.
      // navigate to every page you want
    } on PlatformException {
      // Handle exception by warning the user their action did not succeed
      // return?
    }
  }

then your link can be like this

YOUR_SCHEME://YOUR_HOST/status

status can be FAILED or DONE

Answered By – Mojtaba Ghiasi

Answer Checked By – Marilyn (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *