1

I'm developing an ionic project. I have follwed all steps to installa Social Sharing and Deeplinks.

This is my schema when I install plugin.

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

But when I share with Social Sharing don't send a url, Social Sharing send as string or via email send some structure as string an other part as url.

e.g. via hangout as string

e.g. via email app://app.com/page --> app:// as string and app.com/page as url

In Social share documentation schema is share(meesage, subject, file, url)

message:string, subject:string, file:string|Array, url:string

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

The app open deeplinks when I tested using browser from codepen.io with hiperlink.

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

But when I share a deeplink send as string.

Why??? Can you help me???

Javier
  • 1,975
  • 3
  • 24
  • 46

2 Answers2

2

I struggled with the same problem, the solution to this is very straight forward:

Do not use custom url schemes

The main reason for not using custom url schemes is that Gmail and other webmail provider indeed destroys links such as "app://...". So there is no way to get this work.

See the following links for details:

Use universal links instead

Universal links is supported by Android und iOS. Since you are already using the ionic-plugin-deeplinks plugin, you already configured a deeplink url. All you have to do is change

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

to

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

For using universal links you need to create configuration files for android and iOS. These files must include application identifiers for all the apps with which the site wants to share credentials. See the following link for details:

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

The file has to be located on your website at exactly

JudgeFudge
  • 1,749
  • 13
  • 18
  • 1
    I do not have a domain. And do not intend to buy one. Will this work without a domain? – krv Feb 27 '18 at 05:35
0

You can also use to get data from custom URL and deep link in our app if exist. Otherwise, redirect to play/app store like this:

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, " "));
}

Call link like: BASE_URL/index.html?lifestoryId=123

Kamlesh Kumar
  • 1,632
  • 2
  • 21
  • 31