Adding Facebook App Invite For Cordova and Phonegap Apps

Step 5)

We will now add the cordova-plugin-facebook4 , but we have to add this plugin a bit differently. We have to provide the Facebook App ID and the Facebook app Name Space name while adding the plugin as follows

Here run the command with your own App ID and App Name, Note that the quotation marks (” “) are necessary.


Step 6)

Now it’s time to code up our app we will start off by coding the index.html file, here I will create a simple page with just one button which when pressed with send the invite.

Make sure to add reference to  cordova.js and script.js file. The cordova.js file will be injected dynamically at build time so you do not need to place any file named cordova.js you just need to add a reference to it. The script.js file needs to created which will contain our code which we will create next.

Step 7)

We will now wire up the button to handle theclick event. In order to sent the App Invite we will need two things, first the App Link that we created in Facebook and the second is a link to an App Image which will appear when the app invite is sent (Typically the app icon is used).

Note here that the App Image that we will use should be an image that is on the web and must be a valid url.

So we will code the script.js file that we linked to the in the index.html file the following way

And just like that, we are done with our app. Now you have the ability to send Facebook App Invites from your Cordova Apps.

Few Important Points and Tips

Before I conclude this post I want to leave you with some Important Tips and Points that I find note worthy.

When you install the cordova-plugins-facebook4 plugin with your App ID and App Name and for some reason you decide to change your app ID or App Name you should remove the plugin and add the plugin again with the new values, changing them in the config.xml file won’t make any difference.

Lastly, note that the app invite will open up the default Facebook app and use it to send the invites without asking for a login if however, the default app is not present then it will open up a dialog box and  prompt for login and then send the invites.



It does take a little bit of configuring when it comes to implementing Facebook App Invites but it’s worth the trouble. You can use Facebook App Invites in a variety of ways one of the most popular way I have seen App Invites being used is offering less Ads or unlocking some feature in your app after the user has Invited some friends.


Download Code:

Code Will Be Sent Via Email


Leave Me Your Questions And Feedback

Getting your feedback inspires me the most so hit me up in the comments here or on the comments section on my YouTube Channel or on twitter @uncutAcademy
Consider Subscribing / Donating
Subscribe To Mailing List
If my site was helpful to you, then please consider donating via paypal:
Prantik Vaghela

Prantik Vaghela (uncutAcademy)

Hi my name is Prantik Vaghela. I have done my Bachelors and Masters in Computer Science and am a web developer and now a Tutor through my blog. :-)