Ticker

6/recent/ticker-posts

Social share || iOS || Swift

Objective
How to share the data from my app to social media?

Solution
 Many of the app requires to share their app data to the social media like Facebook, twitter etc,. So here the simple way to share your app information or data to the social media. 

As iOS provided a default solution to overcome the social sharing. It provided Social.framework, where we can find SLComposeViewController to launch the share dialog.


So let’s get into the coding part, by creating new project. To create new project open your Xcode developer tool, File/New/Project then name you example project. After creating your project follow the below two steps to add the Social.framewok to your app.



After adding Social.framework, let’s get into add some simple UI which you would like to share it on the social media. Here in my example I have created some sample UI and made action connects between storyboard and class associated.



Facebook Sharing :
If you want to share the data in Facebook from your application, your mobile device must link to the Facebook app settings as shown below.  Open Settings/Facebook/, then add your Facebook account and click on login.



After configuring facebook account, add the following code block to your method.


Twitter Sharing :
If you want to share the data in Twitter from your application, your mobile device must link to the Facebook app settings as shown below.  Open Settings/Twitter/, then add your Twitter account and click on login.


After configuring twitter account, add the following code block to your method.

The final output looks like the below

      



Helper method code block

Post a Comment

0 Comments