打开特定URL后,将用户从浏览器重定向到我的应用程序

esm*_*eil 13 payment android intentfilter

我写了一个应用程序,用户点击购买按钮他/她重定向到互联网浏览器(例如:铬)和付款后我想他回到我的应用程序(我的活动),所以我发现我应该使用Intent-Filter但它对我不起作用!

我在清单中添加这些代码:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:host="returnApp" android:scheme="myapp"></data>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

当我打开这样的网址时:

MYAPP:// returnApp状态= 1

我的应用程序无法打开.

pep*_*kin 14

尝试打开它myapp://returnApp/?status=1(添加尾部斜杠字符).发生这种情况是因为路径参数定义为默认值/.

不幸的是,你无法完全匹配空字符串.正如文件所述:

URI的路径部分必须以/开头.

如果您确实需要使用完全url启动应用程序,则myapp://returnApp?status=1可以将android:pathPattern=".*"参数添加 到数据子句中

<intent-filter>
    ...
    <data android:host="returnApp" android:scheme="myapp" android:pathPattern=".*"></data>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

具有数据的Intent过滤器android:pathPattern=".*"将匹配任何路径,包括空路径.


sat*_*nfo 5

  1. 打开 Firebase 应用
  2. 点击动态链接
  3. 在 firebase 上创建您自己的重定向回调链接,例如https://example.page.link/payment

检查 Firebase 图像设置

  1. manifest.xml 文件上的设置链接,如以下代码

<intent-filter android:label="@string/app_name" android:autoVerify="true">
           <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
               <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="https"
                    android:host="example.page.link" android:path="/payment"/>
                <data android:scheme="http"
                    android:host="example.page.link" android:path="/payment"/>
    </intent-filter>
Run Code Online (Sandbox Code Playgroud)

  1. 运行你的应用
  2. 检查 android 手机浏览器上的 firebase 链接
  3. 这是工作是的