因此,我有一个iOS/Android Ionic Cordova应用程序,它使用ionic- plugin -deeplinks插件。当AndroidManifest.xml中包含以下内容时,该插件无法正常工作:
<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="synapticforce.com" android:pathPrefix="/" android:scheme="https" />
<data android:host=" " android:pathPrefix="/" android:scheme=" " />
<data android:host=" " android:pathPrefix="/" android:scheme=" " />
<data android:host=" " android:pathPrefix="/" android:scheme=" " />
<data android:host=" " android:pathPrefix="/" android:scheme=" " />
</intent-filter>
但是,当我把它放在它的位置时,它工作得很好:
<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:scheme="yourekamobile" />
</intent-filter>
然而,每当我ionic prepare
if时,就会将我的修复重写回原来的不起作用的方式。我尝试更改了cordova的父级config.xml
以及plugin.xml parent/plugins/ionic-plugin-deeplinks
文件夹中的一些内容,但它仍然会被覆盖到原来损坏的方式。然后我进入parent/platforms/android/android.json
,将它编写原始版本的位置更改为我的版本,并且它始终构建得很好。
所以我很高兴它能工作,但我的问题是为什么它能工作?android.json
是如何构建的?编辑那个文件是正确的吗,还是有什么东西是我应该编辑的呢?
发布于 2021-08-29 16:20:06
自从这篇文章发布以来很久了,但我也遇到了同样的问题,以下是我是如何修复它的。
如果你进入插件plugin.xml文件,你可以看到它是这样做的…
<config-file target="AndroidManifest.xml" parent="/manifest/application/activity">
<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="$URL_SCHEME" />
</intent-filter>
<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:scheme="$DEEPLINK_SCHEME" android:host="$DEEPLINK_HOST" android:pathPrefix="$ANDROID_PATH_PREFIX" />
<data android:scheme="$DEEPLINK_2_SCHEME" android:host="$DEEPLINK_2_HOST" android:pathPrefix="$ANDROID_2_PATH_PREFIX" />
<data android:scheme="$DEEPLINK_3_SCHEME" android:host="$DEEPLINK_3_HOST" android:pathPrefix="$ANDROID_3_PATH_PREFIX" />
<data android:scheme="$DEEPLINK_4_SCHEME" android:host="$DEEPLINK_4_HOST" android:pathPrefix="$ANDROID_4_PATH_PREFIX" />
<data android:scheme="$DEEPLINK_5_SCHEME" android:host="$DEEPLINK_5_HOST" android:pathPrefix="$ANDROID_5_PATH_PREFIX" />
</intent-filter>
</config-file>
如果您在该文件中再往上看一点,它会将所有这些变量设置为空或'/‘。
这就是设置android.json和AndroidManifest.xml的方法。
为了解决这个问题,我在config.xml中添加了以下内容来覆盖这些“默认”设置。可能值得一提的是,下面的代码被放置在与标签相同的级别上,因此它实际上并不在这两个标签中。
<plugin name="ionic-plugin-deeplinks" spec="1.0.22">
<variable name="URL_SCHEME" value="myapp" />
<variable name="DEEPLINK_SCHEME" value="https" />
<variable name="DEEPLINK_HOST" value="temp-site.ngrok.io" />
<variable name="ANDROID_PATH_PREFIX" value="/app-auth" />
<variable name="DEEPLINK_2_SCHEME" value="https" />
<variable name="DEEPLINK_2_HOST" value="temp-site.ngrok.io" />
<variable name="ANDROID_2_PATH_PREFIX" value="/app-auth" />
<variable name="DEEPLINK_3_SCHEME" value="https" />
<variable name="DEEPLINK_3_HOST" value="temp-site.ngrok.io" />
<variable name="ANDROID_3_PATH_PREFIX" value="/app-auth" />
<variable name="DEEPLINK_4_SCHEME" value="https" />
<variable name="DEEPLINK_4_HOST" value="temp-site.ngrok.io" />
<variable name="ANDROID_4_PATH_PREFIX" value="/app-auth" />
<variable name="DEEPLINK_5_SCHEME" value="https" />
<variable name="DEEPLINK_5_HOST" value="temp-site.ngrok.io" />
<variable name="ANDROID_5_PATH_PREFIX" value="/app-auth" />
</plugin>
我刚接触Cordova,所以我相信有更好的方法来做这件事(也许用'after‘钩子?)但这是我快速而肮脏的解决方案。
https://stackoverflow.com/questions/48232782
复制相似问题