linking.getInitialurl()Promise Promise Prome Consolves始终仅在不运行时null
我如何通过ADB运行DeepLink:
adb shell am start -W -a android.intent.action.VIEW -d "https://my.site.com/my/path" com.my.app.package
在此AndroidManifest.xml中:
<manifest ...>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https"/>
</intent>
</queries>
...
<application>
<activity>
<intent-filter 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:host="my.site.com"
android:pathPrefix="/my/path"
android:scheme="https" />
</intent-filter>
</activity>
</application>
</manifest>
在MainActivity.java中,应用程序关闭我正确地链接了,但似乎并未传递给RN层:
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this);
Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
System.out.println("[MainActivity][onCreate] action="+action);
if(data != null) {
System.out.println("[MainActivity][onCreate] data="+data.toString());
}
super.onCreate(savedInstanceState);
}
React Native版本:0.66
在React Antive代码上
Linking.addEventListener('https', handler);
...
Linking.getInitialURL().then(url => {console.log(JSON.stringify(url));}
: 处理程序
与事件触发有关时始终在应用程序中或打开时,我会得到URL recrectyl。
linking.getInitialUrl()
始终 null ,事件侦听器在关闭应用程序时永远不会发射。
在iOS上都可以正常工作。
App State | iOS | Android |
---|---|---|
打开了 | 当 | 的 |
✅✅✅✅✅✅✅✅✅✅✅✅❌✅❌✅❌✅❌✅❌✅✅❌✅❌❌❌❌❌❌✅✅❌❌❌✅✅✅✅✅✅❌❌❌✅❌✅✅✅✅✅✅✅✅✅❌❌❌❌✅❌✅❌❌✅✅✅✅✅✅ | 处理 | 。 |
传递 | 上 | URL |
应用程序在Android上关闭时,从深链路
如果需要更多信息,请询问它们,我将更新此问题。
How I run deeplinks via adb:
adb shell am start -W -a android.intent.action.VIEW -d "https://my.site.com/my/path" com.my.app.package
In this AndroidManifest.xml:
<manifest ...>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https"/>
</intent>
</queries>
...
<application>
<activity>
<intent-filter 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:host="my.site.com"
android:pathPrefix="/my/path"
android:scheme="https" />
</intent-filter>
</activity>
</application>
</manifest>
In MainActivity.java with App closed I get the deeplink correctly, but it seems to be not passed to the RN layer:
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this);
Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
System.out.println("[MainActivity][onCreate] action="+action);
if(data != null) {
System.out.println("[MainActivity][onCreate] data="+data.toString());
}
super.onCreate(savedInstanceState);
}
React native version: 0.66
On the React Native code:
Linking.addEventListener('https', handler);
...
Linking.getInitialURL().then(url => {console.log(JSON.stringify(url));}
the handler
related to event fires always when app is in background or opened and I get the url correctyl.
The Linking.getInitialURL()
resolves always null and the event listener never fires when app is closed.
On iOS all works fine.
App state | iOS | Android |
---|---|---|
opened | ✅ | ✅ |
background | ✅ | ✅ |
closed | ✅ | ❌ |
I need React Native handles the URL passed from the deep link when the App is closed on Android.
If more info are needed, please ask for them and I will update this question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
路径:android/app/src/main/main/androidmanifest.xml
,您的浏览的刻板标签必须在.mainactivity的活动中
:
path : android/app/src/main/AndroidManifest.xml
where your intent-filter tag of BROWSABLE must be in activity of .MainActivity
example :
添加新的新意图:
例如,我的动态链接是: https://myappname.link/k5ucqpw3r2uh1e
强> https
Add a fresh new Intent:
for example my dynamic link is: https://myappname.link/k5uCqpw3R2Uh1E
therefor the android:scheme would be https