如何解决指向 localhost:8100/register/1234 的链接可在网络上使用,但我似乎无法在 Android 应用程序上实现
总而言之,我正在制作一个带有注册过程的 Ionic Angular 应用程序。 过程非常简单,用户注册,发送一封带有链接的电子邮件(出于测试目的,链接为 https://localhost:8100/register/:urlRandomlyCreated),当用户点击链接时,它会打开网页在正确的组件上,使用正确的信息,一切顺利。
当我尝试在我的 Android 手机上测试它时,我发现我需要更改 url,因为 localhost:8100 不会在手机上打开(并且因为如果应用程序投入生产,带有 localhost 的电子邮件将不会很不错)。经过一番研究,我发现我需要包含一个意图过滤器来打开应用程序而不是浏览器,所以我这样做了。
AndroidManifest.xml
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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:scheme="http" android:host="www.myApp.com" />
</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:scheme="https" android:host="www.myApp.com" />
</intent-filter>
MainActivity.java
package myApp;
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;
import java.util.ArrayList;
import com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(savedInstanceState,new ArrayList<Class<? extends Plugin>>()
{{
add(GoogleAuth.class);
add(com.getcapacitor.community.facebooklogin.FacebookLogin.class);
}});
}
}
所以现在当我在手机中打开带有链接 https://www.myApp.com/register/as12qw4 的电子邮件时,它会问我是要打开浏览器还是应用程序,这很完美,但是当应用程序打开时,它只会在通用着陆页,而不是正确的路线。
如果有人能帮忙,那就太好了,
提前致谢
编辑:
这对我有用https://capacitorjs.com/docs/guides/deep-links
希望它对其他人有用,
最好的问候
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。