开发者

Deeplinking using GWT History Token within a Facebook iFrame Canvas

I would like to deep link directly to a GWT app page within a Facebook iFrame Canvas.

The first part is simple using GWT's History token with URLs like:

http://www.example.com/MyApp/#page1

which would open page1 within my app.

Facebook Apps use an application url like:

http://apps.facebook.com/myAppName

which frames my Canvas Callback URL

http://www.example.com/MyApp/

Is there a way to specify a canvas callback url (or 开发者_运维百科bookmark url) which will take the user to a specific page rather than the index page?

Why? you may ask. Besides all the benefits of deep links...

  • I want the "Go To Application" url to take users to an index page w/ marketing material (the canvas callback url)

  • I want the "Bookmark URL" to take (likely returning) users to a login page and bypass downloading the marketing content (and that huge SWF file).


This may seem to be a hack but here it goes.

Facebook allows the application to tack on parameters to the url ?x=123

So I'm checking the window location to see if it contains my special 'page' parameter and loading that page. Below is my solution given that I'm using GWT + gwt-presenter's PlaceManager class.

The application deep url ends up being http://apps.facebook.com/myAppName?page=page1

    EventBus eventBus = injector.getEventBus();

    // Load PlaceManager so it can start listening
    PlaceManager placeManager = injector.getPlaceManager();
    String currentPlace = History.getToken();

    String place = Window.Location.getParameter( "page" );
    if (place != null && !place.isEmpty()) {
        // send user to the place on the URL line
        eventBus.fireEvent( new PlaceRequestEvent( new PlaceRequest( new Place (place) ) ));

    } else if ("".equals(currentPlace)) {
        // Nothing in URL, load default GWTpage
        eventBus.fireEvent( new PlaceRequestEvent(new PlaceRequest( IndexPresenter.PLACE)));

    } else {
        // fire a body to the Place Manager to activate the requsted Place
        placeManager.fireCurrentPlace();
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜