1

Lync presence indicator works fine in IE but does not work in Firefox or Chrome.

After reading blogs I know that it calls name.dll through ActiveX which is possible in IE directly. I have searched for Firefox and found some link I have implemented, but no success.

I know this should work in Firefox as SharePoint default presence indicator works in Firefox.

Here is my code

if (IsSupportedNPApiBrowserOnWin()) {
    try {
        if (window.ActiveXObject) {
            nameCtrl = new ActiveXObject("Name.NameCtrl");

        } else {
            nameCtrl = CreateNPApiOnWindowsPlugin("application/x-sharepoint-uc");
        }

        html += '<span class="ms-imnSpan"><a href="#" onclick="IMNImageOnClick(event);return false;" class="ms-imnlink ms-spimn-presenceLink" >' +
                    ' <span class="ms-spimn-presenceWrapper ms-spimn-imgSize-10x10"><img onload="IMNRC(\'kaushal.khamar@xxxxx.com\')" name="imnmark"' +
                    ' title="' + currentDataItem.PreferredName + '" ShowOfflinePawn="1" class="ms-spimn-img ms-spimn-presence-disconnected-8x72x32" src="/_layouts/15/images/spimn.png?rev=23" ' +
                    ' alt="' + currentDataItem.PreferredName + '" sip="kaushal.khamar@xxxxx.com" id="imn_' + currentDataItem.EmployeeNumber + ',type=sip" /></span></a></span></span>';

    }
    catch (ex) { }
}




function CreateNPApiOnWindowsPlugin(b) {
   var c = null;
   if (IsSupportedNPApiBrowserOnWin())
    try {
                     c = document.getElementById(b);
                     if (!Boolean(c) && IsNPAPIOnWinPluginInstalled(b)) {
                             var a = document.createElement("object");
                             a.id = b;
                             a.type = b;
                             a.width = "0";
                             a.height = "0";
                             a.style.setProperty("visibility", "hidden", "");
                             document.body.appendChild(a);
                             c = document.getElementById(b)
                        }
        } catch (d) {
    c = null
}
return c
}
2
+50

Use of NPAPI plugins are disabled in Chrome since 1 Sep 2015, please read more here. https://support.google.com/chrome/answer/6213033?hl=en

Not sure how to get it enabled, i thought a flag would be there to enable it back, but its not available. only PPAPI plugins can be enabled.

Similarly for Firefox as well, they have changed the way they support from 'always enabled' to 'click to enable', please read more here. https://blog.mozilla.org/security/2014/02/28/update-on-plugin-activation/

0

For Firefox Open menu -> Add-ons-> Plugins. In plugins select Microsoft Office (With description: The plugin allows you to have a better experience with Microsoft SharePoint) and set Always Activate

  • I have done this. but can't solve my problem. – Kaushal Khamar Sep 30 '15 at 8:56
  • Do Lync presence indicators work for users in standard peoplepicker fields in Firefox? – user3086866 Sep 30 '15 at 9:49
  • I have checked it in Firefox (version 41.0) with activated Microsoft Office 2013 plugin. Lync presence indicators for users work fine – user3086866 Sep 30 '15 at 10:02
0

Extension/plugins which are used in Chrome and Firefox to support presence indicator are here which i discover after research and what i have conclude is.

Chrome: Use of NPAPI plugins are disabled in Chrome since 1 Sep 2015, please read more here. https://support.google.com/chrome/answer/6213033?hl=en

FireFox intended to discontinue support for the npspwrap.dll and similar extensions in August or September 2015.


EDIT:

After some work and research now its works in Firefox and IE

$(document).ready(function () {
    try {
            if (window.ActiveXObject) {
                nameCtrl = new ActiveXObject("Name.NameCtrl");

            } else {
                nameCtrl = CreateNPApiOnWindowsPlugin("application/x-sharepoint-uc");
            }
            attachLyncPresenceChangeEvent();
        }
    catch (ex) { }
});



    function IsSupportedNPApiBrowserOnWin() {
        return true; // SharePoint does this: IsSupportedChromeOnWin() || IsSupportedFirefoxOnWin()
    }

    function IsNPAPIOnWinPluginInstalled(a) {
        return Boolean(navigator.mimeTypes) && navigator.mimeTypes[a] && navigator.mimeTypes[a].enabledPlugin
    }

    function CreateNPApiOnWindowsPlugin(b) {
        var c = null;
        if (IsSupportedNPApiBrowserOnWin())
            try {
                c = document.getElementById(b);
                if (!Boolean(c) && IsNPAPIOnWinPluginInstalled(b)) {
                    var a = document.createElement("object");
                    a.id = b;
                    a.type = b;
                    a.width = "0";
                    a.height = "0";
                    a.style.setProperty("visibility", "hidden", "");
                    document.body.appendChild(a);
                    c = document.getElementById(b)
                }
            } catch (d) {
                c = null
            }
        return c
    }

    function showLyncPresencePopup(userName, target) {
        if (!nameCtrl) {
            return;
        }

        var eLeft = $(target).offset().left;
        var x = eLeft - $(window).scrollLeft();

        var eTop = $(target).offset().top;
        var y = eTop - $(window).scrollTop();

        nameCtrl.ShowOOUI(userName, 0, x, y);
    }

    function hideLyncPresencePopup() {
        if (!nameCtrl) {
            return;
        }
        nameCtrl.HideOOUI();
    }

    function getLyncPresenceString(status) {

        switch (status) {
            case 0:
                return 'available';
                break;
            case 1:
                return 'offline';
                break;
            case 2:
            case 4:
            case 16:
                return 'away';
                break;
            case 3:
            case 5:
                return 'inacall';
                break;
            case 6:
            case 7:
            case 8:
            case 10:
                return 'busy';
                break;
            case 9:
            case 15:
                return 'donotdisturb';
                break;
            default:
                return '';
        }
    }

    function attachLyncPresenceChangeEvent() {
        if (!nameCtrl) {
            return;
        }
        nameCtrl.OnStatusChange = onLyncPresenceStatusChange;
    }

    function onLyncPresenceStatusChange(userName, status, id) {
        var presenceClass = getLyncPresenceString(status);

        var userElementId = getId(userName);
        var userElement = $('#' + userElementId);
        removePresenceClasses(userElement);
        userElement.addClass(presenceClass);

    }

    function removePresenceClasses(jqueryObj) {
        jqueryObj.removeClass('available');
        jqueryObj.removeClass('offline');
        jqueryObj.removeClass('away');
        jqueryObj.removeClass('busy');
        jqueryObj.removeClass('donotdisturb');
        jqueryObj.removeClass('inacall');
    }

    function getId(userName) {
        return userName.replace('@', '_').replace('.', '_');
    }

And HTML is

html += '<div onmouseout="hideLyncPresencePopup()" onmouseover="showLyncPresencePopup(\'kaushal.khamar@xxxx.com\', this)" class="user" id="kaushal_khamar_xxxx.com">kaushal.khamar@xxxx.com</div>';

This code works fine in Firefox and IE both.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.