【问题标题】:Deeplink not work with SocialSharing深层链接不适用于 SocialSharing
【发布时间】:2018-06-26 17:27:08
【问题描述】:

我正在开发一个离子项目。 我已按照所有步骤安装社交共享和深层链接。

这是我安装插件时的架构。

ionic cordova plugin add ionic-plugin-deeplinks --variable URL_SCHEME=app --variable DEEPLINK_SCHEME=https --variable DEEPLINK_HOST=app.com --variable ANDROID_PATH_PREFIX=/

但是当我与社交分享分享时,不要发送 url,社交分享以字符串形式发送或通过电子邮件发送一些结构作为字符串,另一部分作为 url。

例如通过环聊作为字符串

例如通过电子邮件 app://app.com/page --> app:// 作为字符串和 app.com/page 作为 url

在社交共享文档架构中是 share(meesage, subject, file, url)

消息:字符串,主题:字符串,文件:字符串|数组,url:字符串

this.socialSharing.share('Lorem ipsum', 'title', null, 'app://app.com/about')
    .then( ()=> {
      console.log('Success');
    })
    .catch( (error)=> {
      console.log('Error: ', error);
    });

当我使用带有 hiperlink 的 codepen.io 的浏览器进行测试时,该应用会打开深层链接。

< h1 >< a href="app://app.com/about" >Click Me< /a>< /h1>

但是当我分享一个深层链接时,会以字符串形式发送。

为什么???你能帮我吗???

【问题讨论】:

    标签: ionic-framework ionic2 ionic3


    【解决方案1】:

    我也遇到过同样的问题,解决方法很简单:

    不要使用自定义网址方案

    不使用自定义 url 方案的主要原因是 Gmail 和其他网络邮件提供商确实破坏了诸如“app://...”之类的链接。所以没有办法完成这项工作。

    查看以下链接了解详情:

    改用通用链接

    Android 和 iOS 支持通用链接。由于您已经在使用 ionic-plugin-deeplinks 插件,因此您已经配置了深度链接 url。 你所要做的就是改变

    • href="app://app.com/about"

    • href="https://app.com/about"

    要使用通用链接,您需要为 android 和 iOS 创建配置文件。这些文件必须包含站点要与之共享凭据的所有应用程序的应用程序标识符。详情见以下链接:

    https://medium.com/@ageitgey/everything-you-need-to-know-about-implementing-ios-and-android-mobile-deep-linking-f4348b265b49

    该文件必须位于您网站上的确切位置

    【讨论】:

    • 我没有域。并且不打算买一个。这在没有域的情况下也能工作吗?
    【解决方案2】:

    如果存在,您还可以使用我们的应用程序中的自定义 URL 和深层链接获取数据。否则,像这样重定向到播放/应用商店:

    index.html

    $(document).ready(function (){
        var lifestoryId = getParameterByName('lifestoryId');
    
            if(navigator.userAgent.toLowerCase().indexOf("android") > -1){
                setTimeout(function () {
                    window.location.href = "http://play.google.com/store/apps/details?id=com.android.xyz&hl=en"; 
                }, 5000);
            }
            if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1){
                setTimeout(function () {
                     window.location.href = "https://itunes.apple.com/us/app/app/id12345678?ls=1&mt=8"; 
                }, 5000);
    
        }
    
        window.location.href = "app://lifestory/info:"+lifestoryId;
    });
    
    function getParameterByName(name, url) {
        if (!url) url = window.location.href;
        name = name.replace(/[\[\]]/g, "\\$&");
        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/\+/g, " "));
    }
    

    拨打链接如:BASE_URL/index.html?lifestoryId=123

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-13
      • 2021-08-04
      • 1970-01-01
      相关资源
      最近更新 更多