Has app installed

Check if the viewer has the app installed. Also possible to check on owner or viewer friends.

<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Has app installed" summary="" description="" author="" author_email="" thumbnail="" screenshot="" height="380">
   <Require feature="opensocial-0.7"/>
   <Require feature="dynamic-height"/>
 </ModulePrefs>
 <Content type="html">
 
 <![CDATA[
 
<script type="text/javascript">
 
// this is a gadget example on how to filter on persons who have the app installed
function loadData(req) {
        var params = {};
        params[opensocial.DataRequest.PeopleRequestFields.FILTER] = opensocial.DataRequest.FilterType.HAS_APP;
        req.add(req.newFetchPersonRequest('VIEWER', params), 'viewer');
	// You can also check all of your friends with VIEWER_FRIENDS
	//req.add(req.newFetchPersonRequest('VIEWER_FRIENDS', params), 'viewer');
        req.send(onLoadData);
}
 
function onLoadData(data) {
        var viewer = data.get('viewer').getData();
		if(viewer != null) {
        	var result = "You (the viewer) have the app installed";
		} else {
        	var result = "You (the viewer) do not have the app installed";
		}
        document.getElementById('message').innerHTML = result;
        gadgets.window.adjustHeight();
}
 
function init() {
        function getViewer() {
                if (opensocial.hasPermission(opensocial.Permission.VIEWER)) {
                        var req = opensocial.newDataRequest();
                        loadData(req);
                } else {
                        document.getElementById('message').innerHTML = 'No permission to see the viewer';
                }
        }
        opensocial.requestPermission([opensocial.Permission.VIEWER], 'This reason sentence is not used at the moment', getViewer);
}
 
gadgets.util.registerOnLoadHandler(init);
 
  </script>
  <div id="message"></div>
  ]]>
  </Content>
</Module>

Example install (Make sure you're not in OpenSocial Sandbox mode)

Example file