0

使用 React Native Linking 和 Firebase 生成动态链接。除非应用程序在后台打开或单击链接时在“托盘”中打开,否则一切正常。如果当有人单击链接时应用程序已经打开,它什么也不做。

我的侦听器是在 componentDidMount 中设置的,就像文档说的那样,但它没有触发。

componentDidMount() {
  Linking.addEventListener('url', this._handleOpenURL);
},

事实上,我已经查看并警告了 componentWillMount()、componentDidMount()、componentWillUpdate()、componentWillUnmount()、componentWillReceiveNewProps() 和 _handleOpenURL(),当我单击链接并“重新打开”时,我什么也没得到后台的应用程序?我究竟做错了什么?

4

1 回答 1

2

想通了,我会留下问题,以防其他人有同样的问题。

结果我只需要将此代码块添加到我的 AppDelegate.m 文件中。

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity
 restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler
{
  return [RCTLinkingManager application:application
                   continueUserActivity:userActivity
                     restorationHandler:restorationHandler];
} 
于 2017-11-15T22:31:59.493 回答