Skip to main content

How to Add Social Share Buttons to Your iOS and Android Apps

According to a recent study, over 30% of all app downloads originate from a friend’s recommendation. That means that someone shared the app with a friend via a link or told them about it in person. This is the ultimate dream: where your product is so great that people are sharing it with friends, yielding free marketing and downloads. Everyone knows that one friend of a friend who struck it rich when his or her app went “viral”. Besides reaching a product market fit that gets people excited to start talking, you’re probably thinking that there’s little you can do to control this behavior.
Wrong! You can influence likelihood to share.
Let me tell you a story. Before our team started Branch, we worked on a photobook app called Kindred. We launched and saw that growth was abysmal. We were seeing less than 1% growth month over month. We knew we had to do something to fix it, so we added a full page screen after an order was completed that asked if the user wanted to share their order with friends. It increased our growth dramatically, and around 27% people who saw the screen ended up successfully sharing their order with friends!

Add Branch to your app

Why do you need Branch for social shares? First off, Branch comes packed with a full stack sharing feature, making it a much easier option than building something custom. If that wasn’t reason enough, you also get the following benefits from using Branch’s sharing feature:
  1. Links that are branded, fully-hosted, and short
  2. Smart app linking functionality
  3. Attribution for clicks, installs, and more
  4. Plus a lot more—but you can discover that on your own!
Here’s an example Branch link for our test app Branch Monster Factory. It works across all platforms (desktop, Android, and iOS) and fits snugly into mobile optimized channels like SMS or social shares.
It’s super quick and easy to get set up with Branch. First, you’ll need to on-board:
  • Create your unique app key
  • Configure your branded short domain (yourapp.app.link)
  • Configure your Branch links to redirect to the App or Play Store, depending on the operating system, as well as Universal Links and Android App Links
  • Add the SDKs to your app for attribution and access to the social share feature

Add a share button to the appropriate screen

So you’re all set up with the beautiful Branch link of your choice, and you’re ready to start driving mobile growth. To learn more, keep reading or request a Branch demo
The first step is to add the social share icon to your app. I’d recommend using one of the free icon sets, such as IconicHere’s an svgfor a share icon from Iconic, and here is the png version:
Create the button in your app and drop in the share icon from above as the unpressed state. For the pressed state, feel free to use this lightened png version. This gives the nice illusion of a response when the user taps it.
After you’ve done that, hook the button up to your code and create a share button tapped handler. This is where you’ll trigger your social share code listed below.

Add social share buttons to your iOS app

Note that this section assumes you’ve gone through the Branch onboarding flow and added the iOS SDKs. If you haven’t, complete that step now. In your view controller where you have added the share button above, start by importing the following header files:
  1. #import "BranchUniversalObject.h"
  2. #import "BranchLinkProperties.h"
Now, in your share button handler, trigger the share sheet with social options with the following code:
  1. - (void)userTappedShare {
  2. // Define the properties that will fill in the open graph tags
  3. // Use a unique identifier for your content as the canonical identifier
  4. BranchUniversalObject *branchUniversalObject = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:@"content1234"];
  5. branchUniversalObject.title = @"This is the title for your social post";
  6. branchUniversalObject.contentDescription = @"This text will appear in the description field of your social post!";
  7. branchUniversalObject.imageUrl = @"https://yourapp.com/this-picture-will-be-shown-on-social.png";
  8. // Define the link properties for analytics and redirection control
  9. BranchLinkProperties *linkProperties = [[BranchLinkProperties alloc] init];
  10. linkProperties.feature = @"share";
  11. // Trigger the share sheet to be displayed
  12. [branchUniversalObject showShareSheetWithLinkProperties:linkProperties
  13. andShareText:@"This text will be the user’s message if supported."
  14. fromViewController:self
  15. completion:^(NSString *activityType, BOOL completed) {
  16. NSLog(@"finished presenting");
  17. }];
  18. }
When this code executes, the user will be presented with the native iOS social share screen as shown below on the left. Selecting Facebook will initiate that post being created as shown in the screen on the right:

Add social share buttons to your Android app

Note that this section assumes you’ve gone through the Branch onboarding flow and added the Android SDKs. If you haven’t, please complete that step now.
  1. void userTappedShare() {
  2. // Define the properties that will fill in the open graph tags
  3. // Use a unique identifier for your content as the canonical identifier
  4. BranchUniversalObject branchUniversalObject = new BranchUniversalObject()
  5. .setCanonicalIdentifier("content1234")
  6. .setTitle("This is the title for your social post")
  7. .setContentDescription("This text will appear in the description field of your social post!")
  8. .setContentImageUrl("https://yourapp.com/this-picture-will-be-shown-on-social.png");
  9. // Define the link properties for analytics and redirection control
  10. LinkProperties linkProperties = new LinkProperties()
  11. .setFeature("sharing");
  12. // Define the style of the share sheet
  13. ShareSheetStyle shareSheetStyle = new ShareSheetStyle(MainActivity.this, "This text will be the user’s message if supported.")
  14. .setAsFullWidthStyle(true)
  15. .setSharingTitle("Share With");
  16. branchUniversalObject.showShareSheet(this, linkProperties, shareSheetStyle, new Branch.BranchLinkShareListener() {
  17. @Override
  18. public void onShareLinkDialogDismissed() {
  19. Log.i("ShareFunction", "Share screen dismissed”);
  20. }
  21. });
  22. }
When this code executes, the user will be presented with the social share screen as shown below on the left. Selecting Facebook will initiate that post being created as shown in the screen on the right:
How to add social share buttons to your Android app
Don’t see your platform here? Branch supports Unity, React Native, Cordova, Xamarin, and many more. See other code snippets here.

Comments

  1. Filament
    In a single WordPress plugin, Filament contains a group of useful features including Flare, a social share button plugin that makes it easy for others to share your blogpost on Twitter, Facebook, Buffer, and more—even spots like Hacker News and Reddit. Other Filament apps include: MailChimp subscribe form, Google Analytics tracking, all-in-one profiles, code management, and share highlighter.

    ReplyDelete

Post a Comment

Popular posts from this blog

web2apk

http://web2apk.com/create.aspx Create App   Intro   About   Changes   MalWare ?   Contact   Privacy Useful Links Bluetooth Mini Keyboards Android Mini PC Reset Android URL App Title Icon or

how to retrieve image from sqlite database in android and display in listview

 Android platform provides several ways to store data in our application. 1. SQLite database 2. SharedPreferences etc For our post, we will only work with SQLite database. First and foremost, we need to understand what an SQLite database is? SQLite database  is an open source SQL database that stores data to a text file on a device. It executes SQL Commands to perform a set of functions, that is, create, read, update and delete operations. On my previous post, I showed how to  store data in SQLite database from edit text, retrieve and populate it in a listview . For this post, I will show the SQLite CRUD operations with images from gallery and text from EditText. We need to understand this; images are stored in SQLite database as BLOB data type. A BLOB is a large binary object that can hold a variable amount of data.  Note, we can only store images in the database as BLOB data type. We need to convert our image path to a bitmap then to bytes. Also

Android Bar Chart Using MpAndroidChart Library Tutorial

https://www.numetriclabz.com/android-bar-chart-using-mpandroidchart-library-tutorial/ Android Bar Chart Using MpAndroidChart Library Tutorial Objective In this tutorial we learn how to implement Bar Chart using MpAndroidChart Library in your Android App. Download Source Code       Step 1 Contents ·        1  Introduction ·        2  Creating Bar chart o    2.1  Create a new Project o    2.2  Adding library in Project o    2.3  Create Layout o    2.4  To Plot Bar Chart §   2.4.1  Initialize the graph id §   2.4.2  Creating a Dataset §   2.4.3  Defining X-axis labels §   2.4.4  Set the data §   2.4.5  Add the description to the chart §   2.4.6  Run your App §   2.4.7  Set the color §   2.4.8  Adding Animations o    2.5  To plot grouped bar chart §   2.5.1  Creating Dataset o    2.6  Get the best of Android plus exclusive deals and freebies in your inbox!