Quick tip: testing if web activities are available

One of the coolest additions to Firefox OS are Web Activities, a function similar to Android’s intents they allow apps to delegate activities to each other quite easily, given devs a way for web apps to interact with each other without much hassle.

I won’t go into the specifics of Web Activities because I am learning to use them myself (more info here) but I wanted to share a quick tip I discovered while in Madrid.

I was intending too use Web Activities for my app to show as an option when the users attempts to play youtube videos. It worked well, but when I tried running it on desktop Firefox as it was, the app froze without any warnings or errors of any type in the console.

To test for the availability of Web Activities, you can simply test for the mozSetMessageHandler function:

if(navigator.mozSetMessageHandler!=undefined){

//this executes if Web Activities are avaliable in the platform

navigator.mozSetMessageHandler('activity', function(activityRequest) {

//do something cool when your app is called from other app

});

}

Somewhat crude, but works

Advertisements

An upcoming web developer and android app-maker with an interest on using reliable tech in creative ways, open source projects and start-ups.

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: