Social Media Sharing in Apache Cordova With ngCordova

Social sharing with Cordova appI’ll show you how to setup easy social sharing with Apache Cordova with special plugin which uses native system share dialog. This is a quite easy method you can use for this. We’ll also use social sharing module of ngCordova to keep our code clean.

Also we’ll consider how to rollback to pure Facebook website sharer for websites.

The main advantage is that any facebook/twitter apps are not required to use this method.

Installing plugin

Installing ngCordova

ngCordova social share plugin page

Using plugin

You can share image, link or message with this plugin. Just use this code to share something via Facebook. Set nulls except of message/image/link if you don’t need to add something to your share.

You can also use “shareViaWhatsApp”, “shareViaTwitter”, “shareViaSMS” and “shareViaEmail” methods except of “shareViaFacebook”.

We can check the availability of each share method. Let’s consider Facebook.

Another share method using in-app browser

First, we’ll need to install in-app browser plugin:

Than you can use the following code to perform share action:

That’s all. Really easy, but I spent a lot of time gathering things together. Any comments are very welcome!

One thought on “Social Media Sharing in Apache Cordova With ngCordova”

  1. Hi, plug in works great except that when my app wants to share a GIF image on whatsapp, whatsapp crashes. This is tested on Android. Please assist.

Leave a Reply

Your email address will not be published. Required fields are marked *