问题描述
fun generateLink(text: String,promo: String): Single<String> = Single.create { emitter ->
AppLinking.newBuilder()
.setUriPrefix(Const.Deeplink.BASE_URL_APPLINKING)
.setDeepLink(Uri.parse(Const.Deeplink.BASE_WEB + addParams(mapOf(Const.Deeplink.ParaM_PROMOCODE to promo))))
.setAndroidLinkInfo(AppLinking.AndroidLinkInfo.newBuilder()
.setAndroidDeepLink(AGS + Const.Deeplink.PACKAGE_NAME_ANDROID)
.build()
)
.setIOSLinkInfo(AppLinking.IOSLinkInfo.newBuilder()
.setIOSDeepLink(AGS + Const.Deeplink.PACKAGE_NAME_IOS)
.setBundleId(Const.Deeplink.PACKAGE_NAME_IOS)
.build()
)
.buildShortAppLinking(ShortAppLinking.LENGTH.SHORT)
.addOnSuccessListener { link ->
Timber.e("${link.testUrl}")
text.plus("\n").plus(link.shortUrl?.toString()).also {
emitter.onSuccess(it)
Timber.e(it)
}
}.addOnFailureListener {
var dr = Const.Deeplink.PACKAGE_NAME_ANDROID
var df = Uri.parse(Const.Deeplink.BASE_WEB + addParams(mapOf(Const.Deeplink.ParaM_PROMOCODE to promo)))
emitter.onError(it)
}
}
但是有错误
com.huawei.agconnect.applinking.AppLinkingException: code: 204865654 message: [AppgalleryConnectLinkManageService]the ios bundleId does not have permission
有人遇到过吗? PACKAGE_NAME_IOS 有效 com.65gb.xxxxx.xxxxx
解决方法
更新
您需要将AppLinking iOS SDK集成到您的bundleID为com.65gb.xxxx.xxxx的iOS项目中,然后通过handleAppLinking接口接收获取配置好的iOSDeepLink。
有关如何在 iOS 中接收 AppLinking 的详细信息,请参阅 document。
确保您的 iOS 应用程序的包 ID 与使用 setBundleId()
方法传递的参数相同。您可以在 AppGallery Connect 中查看包 ID。
应用链接用于项目下的所有应用。您只能在 AppGallery Connect 中包名称在同一项目中的应用之间实现重定向。