Trigger click on linkedin javascript auth button doesn't work in ios and android (at least)

2.2k views Asked by At

I'm trying to create a trigger for the linkedin button generated by the js api. It works perfect in desktop browsers but on mobile browsers (ios, android browser) it doesnt work.

Here is the code:

Html:

<script type="text/javascript" src="http://platform.linkedin.com/in.js">
  api_key: i6fpkmpak7qu
  authorize: true
</script>
<a href="#ln" title="Autentificare cu LinkedIn" id="sidebar_auth_ln" class="ln_auth_link"></a>
<div class="hidden_ln_login_holder">
    <script type="IN/Login" data-onAuth="onLinkedInAuth"></script>
</div>

Javascript:

$(document).ready(function(){
    $('.ln_auth_link').click(function() {
        DIV = $(this).next();
        $('a span:first', DIV).live('click', function() { return true; });
        // also tried $('a span:first', DIV).click();, $('a span:first', DIV).trigger('click')
        return false;
    });
});

As I mentioned above, this is a mobile issue only. Plus, if i use this code

alert($('a span:first', DIV).html());

it pops up "ln", just like in the desktop browser.

Also, the login works without problems if I don't hide the part and I tap right on it.

Here's the address where the code is live: http://test[dot]lacontabil[dot]ro

Any ideas? Thank you!

1

There are 1 answers

0
urfusion On
 <script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key:
//onLoad: onLinkedInLoad
scope: r_basicprofile r_emailaddress r_fullprofile
authorize:true
</script>

<script type="text/javascript">
function onLinkedInAuth() {
IN.API.Profile("me")
.fields("firstName", "lastName", "industry", "location:(name)", "picture-url", "headline", "summary", "num-connections", "public-profile-url", "distance", "positions", "email-address", "educations", "date-of-birth")
.result(displayProfiles);
IN.UI.Share().params({
url: "http://www.example.com"
}).place()
}
function displayProfiles(profiles) {
console.log(profiles);
member = profiles.values[0];
}
jQuery(document).ready(function(){
jQuery("#linkdinlog").click(function(){
IN.UI.Authorize().place();
IN.Event.on(IN, "auth", onLinkedInAuth);
});
});
</script>
<a href="javascript:void(0)" id="linkdinlog">link</a>

you can call that on click on custom button