Using a Hidden App in Your Jive Community

Version 44

    WARNING: This document describes an unsupported feature of the Jive Platform. This feature is for trial only and may not be supported in future versions of Jive. It can result in performance problems for your Jive instance. Use at your own risk. Please send us feedback if you have any questions.

     

    Starting with the June 2014 Jive Cloud release, you can create a hidden app in your Jive community that runs whenever a user browses to a page in the community. From this app, you can grab relevant information about the current context (using the Jive Open Social API) and pass it to another service.

     

    Instructions

     

    Below are the steps required to enable this functionality.

    (If you need assistance creating a basic app, refer to Getting Started > Creating an App with the Jive Node SDK.)

     

    1. Create a "jive/actions/rtc" app action contribution in app.xml.
      <action id="my-unique-id-goes-here" 
              path="jive/actions/rtc" 
              view="hiddenapp" 
              label="Hidden App"/>
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    2. Specify a Content element  in the same app.xml file using the view name as specified above. Use 0 as the preferred_height and preferred_width.
      <Content type="html" view="hiddenapp" href="hiddenapp.html" 
               preferred_height="0" preferred_width="0" />
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    3. Within the html file specified in your content element (hiddenapp.html in the example above), run any code within the registerOnLoadHandler function.
      gadgets.util.registerOnLoadHandler(function () {
           // Run code here
      
      });   
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      

     

    Example

     

    The following sample app.xml sets up the Hidden App app action.

     

    <?xml version="1.0" encoding="UTF-8"?>
    <Module specificationVersion="1">
      <ModulePrefs title="Hidden App"
                   description="Hidden App Description"
                   author="Your Name"
                   author_affiliation="YourCompany"
                   author_email="youremail@yourcompany.com">
    
        <!-- Commonly used features -->
        <Require feature="jquery-1.6"/>
        <Require feature="osapi"/>
        <Require feature="opensocial-data" />
        <Require feature="jive-core-v3" />
        <Require feature="jive-event" />
        <Require feature="jive-core-v3-resolver" />
    
        <Require feature="actions">
             <Param name="action-contributions">
                  <![CDATA[
                  <action id="com.jivesoftware.hiddenapp"
                          path="jive/actions/rtc"
                          view="hiddenapp"
                          label="Hidden App"/>
                  ]]>
             </Param>
        </Require>
    
      </ModulePrefs>
    
      <Content type="html" view="home,canvas" href="hello.html" preferred_height="400" />
    
      <Content type="html" view="hiddenapp" href="hiddenapp.html"
               preferred_height="0" preferred_width="0" />
    
      </Content>
    </Module>
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

     

    And the following HTML file (hiddenapp.html) contains the hidden app functionality. It sends a log to the console whenever the user browses a profile page, a document, or a group.

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
      "http://www.w3.org/TR/html4/strict.dtd">
    
    <html lang="en">
    
               <script type="text/javascript">
    
                    gadgets.util.registerOnLoadHandler(function () {
    
                        // Log whenever this code starts
                       console.log('HIDDEN APP: Hello World!');
    
                        // Get information about the selected page
                       osapi.jive.core.container.getLaunchContext(function (selection) {
    
                          var type = selection.jive.content.type;
                          var contentid = selection.jive.content.id
                          switch (type) {
    
                              case "osapi.jive.core.User":
    
                                   // Grab information about the user whose profile we're viewing
                                   osapi.jive.corev3.people.get({ "id" : contentid })
                                  .execute(function (osapiResponse) {
                                       console.log('HIDDEN APP: Currently viewing the profile page for '+osapiResponse.displayName);
                                   });
                                   break;            
    
                              case "osapi.jive.core.Document":
               
                                   // Grab information about the document we're viewing
                                  osapi.jive.corev3.contents.get({entityDescriptor: [102,contentid]})
                                  .execute(function (osapiResponse) {
                                       console.log('HIDDEN APP: Currently viewing a document with subject '+osapiResponse.list[0].subject);
                                  });
                                   break;            
    
                              case "osapi.jive.core.Group":
               
                                   // Grab information about the group we're viewing
                                  osapi.jive.corev3.places.get({entityDescriptor: [700,contentid]})
                                  .execute(function (osapiResponse) {
                                       console.log('HIDDEN APP: Currently viewing a group named '+osapiResponse.list[0].name);
                                  });
                                   break;            
    
                           }         
                       });
                   });
             </script>
    
    </html>
             
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

     

     

    For more information: