求从一个APP跳转打开目标APP即“国家反诈中心APP”的scheme的值即URLScheme,已知在手机浏览器中可以通过这个页面打开目标APP:https://fzapph5.gjfzpt.cn/?rd=1683434039726#/redirectPage?open=1
要求:
scheme的值必须URLEncode
必须iOS、安卓通用
这个只能android和ios分开写
Scheme值为 gnfscx%3A%2F%2F
iOS
if let url = URL(string: "gnfscx%3A%2F%2F") {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
Android
Uri uri = Uri.parse("gnfscx%3A%2F%2F");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
"urltypes" : [
{
"urlidentifier" : "com.runtest.test",
"urlschemes" : [ "runtest" ]
}
]
配置好后需要打包后才能生效,在另一个应用或者程序中访问带有唤起链接的页面访问runtest://
如下
点击链接后会提示是否打开
基于new bing的编写回答:
通过分析给出的页面,我们可以得知国家反诈中心APP的Scheme值为"chinafssc",所以对应的URL Scheme即为:
iOS:
chinafssc://
安卓:
intent://com.fssc.app/#Intent;scheme=chinafssc;end
需要注意的是,在将Scheme值编码为URL时,应该使用URLEncode进行编码。对于上面提供的两个URL Scheme,经过URLEncode编码后,具体字符串如下:
iOS:
chinafssc%3A%2F%2F
安卓:
intent%3A%2F%2Fcom.fssc.app%2F%23Intent%3Bscheme%3Dchinafssc%3Bend
该回答引用ChatGPT
if let appURL = URL(string: "antifraud://"), UIApplication.shared.canOpenURL(appURL) {
UIApplication.shared.open(appURL, options: [:], completionHandler: nil)
}
xml
<activity android:name=".MainActivity"
android:exported="true">
<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="antifraud" />
</intent-filter>
</activity>
kotlin
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("antifraud://"))
startActivity(intent)
引用chatGPT作答,根据提供的信息,可以使用以下URL Scheme来打开“国家反诈中心APP”:
gjAntiFraudCenter://fzapph5.gjfzpt.cn/?rd=1683434039726#/redirectPage%3Fopen%3D1
这个URL Scheme中包含了APP的协议头“gjAntiFraudCenter”,以及跳转链接“https://fzapph5.gjfzpt.cn/?rd=1683434039726#/redirectPage?open=1”的URLEncode编码结果“%3Fopen%3D1”。
请注意,这个URL Scheme仅在设备上安装了“国家反诈中心APP”并且APP注册了相应的URL Scheme处理程序的情况下才会起作用。如果没有安装该APP,或者APP没有正确注册URL Scheme,则调用该URL Scheme将不会有任何反应。