在 Ionic 4/Angular 中创建一个带有 ID 的 url link

Create a url link with an ID for an action in Ionic 4/Angular

我正在使用 Ionic 4/Angular。我想向用户发送一封带有嵌入式 link 的电子邮件以批准一项操作。一旦他们点击 link,它会将他们重定向到网页或返回到本机应用程序上的页面,以向他们表明他们已批准该操作。我将使用 url 中的 ID 来识别用户并将 value="yes" 存储在 FireBase 中。我怎么能做到这一点?我可以处理数据库部分,但不知道如何使用 ID 创建 url,也不知道如何将 ID 参数传回以进行进一步操作。

SO 中有类似的主题,但与 Ionic/Angular 无关。我用谷歌搜索并找到了 "Ionic Deeplink" 的概念,但不确定它是否有助于实现我的目标或如何实现它。希望有人能帮忙。

你走在正确的道路上

Deeplinks plugin and Branch IO都提供了你要找的东西,流程如下:

我个人对 Deeplinks 有疑问,我们最终使用了 Branch IO,这里是 their documentation

  1. 您 API 中的端点有一个 "base url" 以 2 个深度 link 选项之一所需的形式注册,然后将 Id 附加到它
  2. 您将 link 放入电子邮件正文并发送

当您配置 Deeplinks 时,您告诉应用程序在设备中 register "a domain",而不是常规的 https://www.yourapp.com/home,您可以执行类似 yourapp://home 的操作,设备会识别出它有一个可以打开 link 的 "kind" 的应用程序,并提示用户是否要转到网络版本,或者本机(应用程序)版本。

更新

Quick start on Branch IO

app.component.ts

initializeApp() {

  //Other initialization here

  Branch.initSession().then(data => {
    if (data['+clicked_branch_link']) {
      this.navCntrller.navigateRoot(data.$deeplink_path);
    }
  });
}

config.xml

<!-- sample config.xml -->
<widget id="com.eneff.branch.cordovatestbed" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  <!-- Branch -->
  <plugin name="branch-cordova-sdk" spec="^3.1.6" />
  <branch-config>
    <branch-key value="key_live_ndqptlgXNE4LHqIahH1WIpbiyFlb62J3" />
    <uri-scheme value="branchcordova" />
    <link-domain value="cordova.app.link" />
    <ios-team-release value="PW4Q8885U7" />
  </branch-config>

解决了!!

我也无法使 'Deeplinks' 工作。但是,我可以重定向到网页并使用 getQueryParam().

获取参数(在本例中为 'id')

link: www.myapp.com/detail?id=1234

 import { Platform } from '@ionic/angular';

 constructor(private platform: Platform){
    console.log(this.platform.getQueryParam('id'));
 }

 // result: 1234