1 / 16

HOW TO INTEGRATE TWITTER AND FACEBOOK SHARING IN IOS APP?

We will be going to learn more about social sharing feature of iOS, As we all know a few years back developers have to make use of facebook and twitter API to provide the sharing feature.<br><br>https://www.loginworks.com/blogs/integrate-twitter-facebook-sharing-ios-app/

rotansharma
Download Presentation

HOW TO INTEGRATE TWITTER AND FACEBOOK SHARING IN IOS APP?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. WELCOME TO LOGINWORKS SOFTWARES

  2. HOW TO INTEGRATE TWITTER AND FACEBOOK SHARING IN IOS APP?

  3. SOCIAL FRAMEWORKAfter the introduction of iOS 6 version, a new framework arrives which is known as “Social Framework”. This framework enables users to integrate your app with any supported social networking services. Currently, it supports Facebook and Twitter. This framework gives you an interface to interact with different social media and it enables you from learning the internals. Even you don’t have to implement any of the Twitter/Facebook APIs, how to handle network connection, handle single sign-on, etc. The social framework simplifies everything.You just need to write a few lines of code to bring up the composer and users can tweet/publish a Facebook post on your app.The social framework comes with a very handy class named SLComposeViewController. The SLComposeViewController class presents a standard view controller for users to compose the tweet or Facebook post. This also allows developers to preset the initial text, attach images and also adding URL to the post, If you want to implement the simple sharing feature, this is the only class you need to know and that we will go through today.If you’re not familiar with the SLComposeViewController, this is what it looks like within your app.So Let’s get started now.

  4. INITIAL SETUP

  5. IMPORT FRAMEWORK Now head to the framework section of your Xcode and add the Social Framework to your application as I mentioned below.

  6. DESIGNING INTERFACE Now we will be going to design the interface for our application and to this, we need to add few objects to our view controller. But first, we will be going to create our own view and to do this. Go to File -> New -> File -> Cocoa Touch Class -> UIViewController . Then name the view controller file as SocialViewController as shown below.

  7. ESTABLISHING CONNECTION BETWEEN VARIABLES AND ELEMENTS Now we need to add few objects to our view controller. UIView – We will be going to add a custom color to our view. I will be using Hexa color #008040 for my design you can choose a color of your choice. UILabel – With the help of this Label I am going to write a text to it which is “Social Sharing Buttons” so that the design looks better here. UIButtons – We will be going to use two buttons here so that we can add action to them later to handle facebook and twitter share feature. After doing all the objects designing our view will looks similar to this.

  8. As you can see that I have added two images to my asset folder and using them to set an image on buttons so that both of them looks different and are identical. Now to make the connection between the objects and view we need to drag and drop all objects one by one to our viewcontroller.h file. Drag the first button which is facebook button and create an action of it. Now drag the second button which is twitter button and create an action to it as shown below.

  9. POINT TO REMEMBER

  10. CHOICE 2If you choose Settings button then it will be going to redirect you to settings of your device through which you can add the details to your social media account and configure it from there, So that next time if you re-run the application then it can easily be going to update the social media post through this application.ADDING TWITTER SUPPORTNow it’s time to add some functionality to Twitter so that we can share our social media update using twitter button also.Twitter is also one of the best ways to share our feeling or some tweet using twitter, iOS provides twitter support using its SocialFramework similar to facebook.STEP 1We will be going to add the code inside our twitter button so that we can use its action to share our tweet on twitter profile.First add your Twitter credentials into your twitter setting inside your iPhone so that it will not ask you, again and again, to add the account to it.STEP 2Add the following code to perform the functionality of the twitter button as shown below.

  11. ADDING IMAGE TO YOUR POST

  12. ADDITIONAL LESSON If you don’t know how to create a custom alert of your choice then I am adding the method to do it below as we know that in iOS 9, The alert view is depreciated and in the place of it we will be going to use alert controller which contains the updated code according to Apple’s guidelines. First, Create an alert controller object and add the title and message and alert type to it.

  13. SUMMARYThis is it, You have successfully made an application that can help you share your status on social media without even using any API and with fewer efforts.As you can see from this tutorial, it’s quite easy to add Twitter and Facebook supports using the Social Framework in iOS 6. If you’re building your app, there is no reason why you shouldn’t use the social features. With this support, it adds values to your app and may boost its popularity.The tutorial introduces the basics of Facebook and Twitter integration. You can try to make a demo application and upload multiple images to the social networks.However, if you want to access more advanced features such as display users’ Facebook email and friend list, you’ll need to understand the Facebook API.I hope you enjoy the tutorial about the social framework. If you want more tutorial related to this then let me know.

  14. Thank you For Watching Connect with This For More Inf^https://www.loginworks.com/blogs/ Call us: +1-434-608-0184

More Related