2

我写了一个使用Applinking Huawei生成链接的方法

  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

下班后 在此处输入图像描述

4

1 回答 1

0

更新

您需要将 AppLinking iOS SDK 集成到您的 bundleID 为 com.65gb.xxxx.xxxx 的 iOS 项目中,然后使用 handleAppLinking 接口接收并获取配置的 iOSDeepLink。

iOS 中如何接收 AppLinking,请参见文档

在此处输入图像描述


确保您的 iOS 应用的包 ID 与使用该setBundleId()方法传递的参数相同。您可以在 AppGallery Connect 中查看包 ID。

应用链接用于项目下的所有应用。您只能在 AppGallery Connect 中包名在同一项目中的应用之间实现重定向。

于 2021-05-19T01:11:28.463 回答