Welcome Developers!

in

Welcome!

in

Call to determine if app installed?

Last post 02-04-2009 9:38 AM by Groove Games. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 10-29-2008 2:20 PM

    Call to determine if app installed?

    If the user gets to the canvas page of my app, is there a call/function that I can use to determine if that user has the app installed?

    If the user does not have the app installed, then I want to show a message that tells them they must install the app first to make it work. Otherwise, the user has the app installed and the working canvas is drawn.

    if ( app_is_installed() )
      { draw_working_canvas() }
    else
      { draw_not_installed_canvas() }

    Thanks.

  • 11-17-2008 3:39 PM In reply to

    • Jason
    • Top 75 Contributor
    • Joined on 06-04-2008
    • Posts 54

    Re: Call to determine if app installed?

     this is what i use for non iframe apps

    function init() {
        var os = opensocial.Container.get();
        dataReqObj = os.newDataRequest();
        var viewerReq = os.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER);
        dataReqObj.add(viewerReq);
        dataReqObj.send(handleRequestMe); //Send request for viewer data
      }

    function handleRequestMe(data) { 
    //var viewer = data.get("viewer");
        console.log('handle req me');
        if (data.hadError()) {    //Handle error using viewer.getError()... 
            document.getElementById('output').innerHTML = strTxt+"<br>You do not currently have this app installed. Please click the <b style >Add this app link</b> above or follow <a href='http://www.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=<app friend ID>' target='_parent'>this link</a> and click on add app.";

         return;
        }  //No error. Do something with viewer.getData()...
        loadpage(data); //this is a function that loads my data.
    }

     

    if you are using Iframes it real easy here is sample in PHP

    if( isset($_GET['installState']) && intval($_GET['installState']) > 0 ){

    //do something

    } else{

    // prompt user to add app

    }

     

    note: installState values: 0 = uninstalle, 1 = new install, 2 installed

     If myspace could combine all their stuff and make same data available for all the APIs, it might not be such a pain to develop, instead of focusing on a half donkey implementation of open social which is still in beta (according to the Google opensocial site).

     

  • 11-24-2008 2:06 AM In reply to

    Re: Call to determine if app installed?

    I now also want to test for the installState=1 state in my javascript to see if it is a new install. How do I access the installState in javascript? In my web browser, I see &newinstall=1 in the URL but I don't know how to access that. Thanks

  • 11-24-2008 7:11 AM In reply to

    • Jason
    • Top 75 Contributor
    • Joined on 06-04-2008
    • Posts 54

    Re: Call to determine if app installed?

     working on this today if i figure it out i'll post it

  • 11-25-2008 1:26 AM In reply to

    Re: Call to determine if app installed?

    By examining the opensocial.Container.get() constructor, I see that it has an object params_. One of its properties is the installState. So the following does what I want:

    window.os = opensocial.Container.get();
    if ( os.params_.installState != "0" && os.params_.viewerid != os.params_.ownerid )
      { top.location.href = appCanvasUrl; }

    Earlier I defined appCanvasUrl to be the URL of my application.

    I put the above fragment in my init(). It basically says, "if the viewer has the app installed (new or existing install) and the viewer is not the owner then redirect to the viewer's app's canvas".

    I need this test/redirect because I found that if I did not have the app installed and I was viewing the canvas of a friend and clicked "Add app", after the install the MySpace system would return me to my friend's canvas -- not my canvas. So the above test ensures that after an install, I will be viewing my canvas rather than my friend's canvas. Note that the above test means that I cannot view my friend's canvas if I have the app installed too -- but that's ok for my app since I want to show the owner's canvas in that case.

  • 11-27-2008 2:48 PM In reply to

    Re: Call to determine if app installed?

    if you don't get owner - the app is not installed

  • 12-05-2008 9:02 AM In reply to

    Re: Call to determine if app installed?

    In my non-iframe JS app, I use this:

    var params = gadgets.views.getParams();

    var surface = params.panelId.replace(/.*_/, '');
    var isOwner = params.ownerid == params.viewerid;
    var hasApp = params.installState;
    var appId = params.appid;
  • 12-06-2008 5:51 AM In reply to

    Re: Call to determine if app installed?

    on myspace

    when owner is null means - the app is not installed

  • 02-04-2009 9:38 AM In reply to

    Re: Call to determine if app installed?

     I have an IFrame application andI need to know if some user accessed the canvas page before installing my application.

    The first time my page is called, it comes with installState=0 (but with owneId specified). In this case I just redirect the user to the application profile page.

    But then, when this user clicks Install this Application in the profile page, he is redirected to the canvas page again, but with all parameters with the same values, including installStatate=0. Shouldn't it be 2 in this case? Is there any way to determine if the user has just installed the application?

    Filed under:
Page 1 of 1 (9 items)