Friday 8 May 2015

share with Facebook from an iOS app


It's amazing to share the experience of one with an app on facebook.  Now it's very easy to integrate social media in iOS app.

To post content, photo or share stories on facebook from an iOS app, Facebook provide the SDK with full support of all the major functionality it have. By using it;s SDK we can directly login to facebook, post data on the timeline or other friends wall and can share the link, photo and posts.


To include these functionality in our app.. some configuration is required.

1) Install the Facebook SDK : Download the latest version of SDK from developers site and install it.

2) Create a facebook app:  First we need to registered as developer on facebook. Then create a facebook  app on developer's site.

and fill in each section for app

  • Bundle ID - iOS Bundle ID that corresponds to your app.
  • iPhone App Store ID - App Store ID.
  • iPad App Store ID -iPad App Store ID if your app is in the store.

3) Configure the Xcode Project:  
     A) Add the SDK for iOS project and add required framework to app.
    
     B)  Edit the .plist file.

       1.Create a key called FacebookAppID with a string value, and add the app ID there.
       2.Create a key called FacebookDisplayName with a string value, and add the Display              Name we  configured in the App Dashboard.
       3.Create an array key called URL types with a single array sub-item called URL Schemes. Give               this a single item with your app ID prefixed with fb.
          This is used to ensure the application will receive the callback URL of the web-based OAuth flow.
4)   In appDelegate.m, add the following code:
               #import <FBSDKCoreKit/FBSDKCoreKit.h>
               #import <FBSDKLoginKit/FBSDKLoginKit.h>
- (BOOL)application:(UIApplication *)application openURL:(NSURL* )url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    
    return [[FBSDKApplicationDelegate sharedInstanceapplication:application
                                                          openURL:url
                                                sourceApplication:sourceApplication
                                                       annotation:annotation];
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    [FBSDKAppEvents activateApp];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

return [ [FBSDKApplicationDelegate sharedInstance] application :application
                 didFinishLaunchingWithOptions:launchOptions]
  }


5) Now our project is configured, we can add different functionality  to our app:
    Sharing
    LogIn With Facebook
    App Events
   Graph API calls


To login with facebook, import the required files and add this code

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
   
[login logInWithReadPermissions:@[@"public_profile", @"email", @"user_friends"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
        
          if (error) {
            
       // Process error
        }
         else if (result.isCancelled) {
           
            // Handle cancellations
        } 
          else {
            
            // If you ask for multiple permissions at once, you
            // should check if specific permissions missing
              
                      if ([result.grantedPermissions containsObject:@"email"]) {
                      
                          NSLog(@"%@",result);
                          // Do work
                      }
                }
    }];


To share photo on facebook, your controller must conform to  <FBSDKSharingDelegate> to handle different state in sharing

//build your photo content
   
    FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc]init];
    photo.image = [UIImage imageNamed:@"tom.jpg"];
    photo.userGenerated = YES;
    
    FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc]init];
    content.photos = @[photo];
    
    FBSDKShareDialog *shareFB = [[FBSDKShareDialog allocinit];
    
    if ([shareFB canShow]) {
    shareFB.shareContent = content;
    
    shareFB.delegate = self;
    [shareFB show];
    }
    else{
        
        UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"can't show the share dialog box" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nilnil ];
        
        [alert show];
        
    }

and add the delegate method

#pragma mark === delegate method
- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results
{
    NSLog(@"completed share:%@", results);
}

- (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
{
    NSLog(@"sharing error:%@", error);
    NSString *message = error.userInfo[FBSDKErrorLocalizedDescriptionKey] ?:
    @"There was a problem sharing, please try again later.";
    NSString *title = error.userInfo[FBSDKErrorLocalizedTitleKey] ?: @"Oops!";
    
    [[[UIAlertView allocinitWithTitle:title message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nilshow];
}

- (void)sharerDidCancel:(id<FBSDKSharing>)sharer
{
    NSLog(@"share cancelled");
}

That's so simple with FBSDK to include the functionality of facebook in our app.

124 comments:

  1. Great post! I am actually getting ready to across this information, is very helpful my friend. Also great blog here with all of the valuable information you have. Keep up the good work you are doing here.
    ios app store

    ReplyDelete
    Replies
    1. really nice info for every one. we are providing best sap training in hyderabad and placements also this key word very useful for more info SAP Success Factors

      Delete
  2. I really enjoyed this posting in which you share a valuable post. Thanks for sharing it.
    Facebook app development companies

    ReplyDelete

  3. You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...

    iOS Training in Chennai
    Android Training in Chennai
    php Training in Chennai

    ReplyDelete
  4. Yeah, Its really good advantages, Thanks for sharing.
    Thanks for sharing about your services, let's visit our site.

    Web Design company in Hubli | web designing in Hubli | SEO company in Hubli

    ReplyDelete
  5. You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting
    for your next post keep on updating these kinds of knowledgeable things...
    iOS App Development Company
    iOS App Development Company

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Hi, Does the Facebook App has to be installed to use this?

    ReplyDelete
    Replies
    1. No, it's not necessary. If Facebook app is installed, then it will open in your app otherwise login process will continue in browser.

      Delete
  8. awesome post presented by you..your writing style is fabulous and keep update with your blogs.ios Online course Bangalore

    ReplyDelete
  9. Thanks for the information. Very helpful blog for people who want know that iOS Training in Ahmedabad, here I am sharing additional details of best iOS App Development just go with this iOS App

    ReplyDelete
  10. Thanks to share.IOS is one of the leading and demanding to design the apps . where the process of software design apps it will be done using java PRogramming language.ios Online Training Bangalore

    ReplyDelete
  11. This is one awesome blog article. Much thanks again. ios Online course Bangalore

    ReplyDelete
  12. You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...
    PSD to Wordpress
    wordpress website development

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. After I read and try to understand this article in conclusion amazingwe are generally grateful for the nearness of this article can incorporate impressively more learning for each one of us. thankful to you.


    Accountants Brighton

    ReplyDelete
  15. After I read and attempt to comprehend this article in conclusion amazingwe are by and large appreciative for the closeness of this article can fuse stunningly all the more learning for every last one of us. appreciative to you.

    Accountants Brighton

    ReplyDelete
  16. I've been surfing on the web more than 3 hours today, yet I never found any stupefying article like yours. It's imperatively worth for me. As I would see it, if all web proprietors and bloggers made confusing substance as you did, the net will be in a general sense more profitable than at whatever point in late memory.

    Tax Advisors

    ReplyDelete
  17. I’m experiencing some small security issues with my latest blog, and I’d like to find something safer. Do you have any suggestions?
    Click here:
    angularjs6 Training in Chennai
    Click here:
    Microsoft azure training in chennai
    Click here:
    angularjs6 Training in Chennai
    Click here:
    angularjs Training in online

    ReplyDelete
  18. Appreciating the persistence you put into your blog and detailed information you provide
    Click here:
    Microsoft azure training in velarchery
    Click here:
    Microsoft azure training in sollinganallur
    Click here:
    Microsoft azure training in btm
    Click here:
    Microsoft azure training in rajajinagar

    ReplyDelete
  19. Really great post, I simply unearthed your site and needed to say that I have truly appreciated perusing your blog entries. I want to say thanks for great sharing.
    Data Science course in Chennai | Data science course in bangalore
    Data science course in pune | Data science online course
    Data Science Interview questions and answers | Python course in Kalyan nagar

    ReplyDelete
  20. Thank you to have shared information, and are very helpful for the reader mobile app development in Singapore

    ReplyDelete
  21. I appreciate that you produced this wonderful article to help us get more knowledge about this topic. I know, it is not an easy task to write such a big article in one day, I've tried that and I've failed. But, here you are, trying the big task and finishing it off and getting good comments and ratings. That is one hell of a job done!

    informatica mdm online training

    apache spark online training

    angularjs online training

    devops online training

    aws online training

    ReplyDelete
  22. Thank you for an additional great post. Exactly where else could anybody get that kind of facts in this kind of a ideal way of writing? I have a presentation next week, and I’m around the appear for this kind of data.
    Microsoft Azure online training
    Selenium online training
    Java online training
    Python online training
    uipath online training

    ReplyDelete
  23. Great article and Very useful, thanks for sharing.

    ExcelR Data Science Course Bangalore

    ReplyDelete
  24. This is also a very good post which I really enjoyed reading. It is not every day that I have the possibility to see something like this..
    date analytics certification training courses

    ReplyDelete
  25. After reading your article I was amazed. I know that you explain it very well. And I hope that other readers will also experience how I feel after reading your article.
    top 7 best washing machine

    ReplyDelete
  26. This is also a very good post which I really enjoyed reading. It is not every day that I have the possibility to see something like this..
    www.technewworld.in
    How to Start A blog 2019
    Eid AL ADHA

    ReplyDelete
  27. I am impressed by the information that you have on this blog. It shows how well you understand this subject.
    pmp certification malaysia

    ReplyDelete
  28. appbiz360 is an iOS app development company with global presence and a portfolio most app developers dream of but can’t maintain.

    ReplyDelete
  29. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

    business analytics course

    data analytics courses in mumbai

    data science interview questions

    data science course in mumbai

    ReplyDelete
  30. iOS App Development Company understand the market pretty well and they develop and design applications that meet the demand of the tech-savvy users.

    ReplyDelete
  31. I was looking to Hire iOS Developers for the same. But after reading this blog, I am very happy to resolve the issue in my app easily without any bugs. Thanks for sharing this wonderful information related to ios app development

    ReplyDelete
  32. https://ireparo4android.blogspot.com/2018/03/open-facebook-links-with-youtube-app-android.html?showComment=1587306482582#c35839455117743092

    ReplyDelete
  33. https://ireparo4android.blogspot.com/2018/03/open-facebook-links-with-youtube-app-android.html?showComment=1587306482582#c35839455117743092

    ReplyDelete
  34. AndroidiOSZone is a leading Mobile app development company in India, USA. where our dedicated team members provide world-class technology solutions to game the competitive market. Share your app idea and Contact Us At 91-9899130284.

    ReplyDelete
  35. The training also covers a concept- based understanding of things like statistics, mining and brushes upon deep learning also. 360DigiTMG data science course in hyderabad

    ReplyDelete
  36. The biggest challenge that many of them face is how to create and update iOS apps for business needs. Organizations need developers who can provide custom iOS app development but the remuneration per hour is huge.

    ReplyDelete
  37. Great post and informative blog. It was awesome to read, thanks for sharing this great content to my vision.Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updatingData Science Training In Chennai

    Data Science Online Training In Chennai

    Data Science Training In Bangalore

    Data Science Training In Hyderabad

    Data Science Training In Coimbatore

    Data Science Training

    Data Science Online Training

    ReplyDelete
  38. Thanks for sharing this information. I really Like Very Much.
    BEST devops online training

    ReplyDelete
  39. Share great information about your blog , Blog really helpful for us . We read your blog , share most useful information in blog . Thanks for share your blog here .
    Instagram Clone

    ReplyDelete
  40. It’s very informative and you are obviously very knowledgeable in this area. You have opened my eyes to varying views on this topic with interesting and solid content.
    Data Analyst Course

    ReplyDelete
  41. Wonderful post!!Thank you for sharing this info with us.
    Python Online Training

    ReplyDelete
  42. To manage the Facebook admin page, you will need to click on the Pages in the left menu from your News Feed. Now, go to your Page and click on Page Settings appears in the bottom left, and click on Page Roles in the left column. Click on Edit appears next to the name of the person whose role you want to change and then, choose a new role from the drop-down menu. Click on Save and call Facebook UK in case if you are facing any issue.
    Facebook Support Number UK.

    ReplyDelete
  43. Great Article. Thank you for sharing! Really an awesome post data science course in Hyderabad

    ReplyDelete
  44. thanks really effective list to boost up ranking in search engine. Surely this was the best comment of all time on blogs,
    iOS app developers in Pakistan

    ReplyDelete
  45. We are a Logistics company, Where EasyWay Logistics is specialized in handling all kinds of Oversized/Project cargoes and General cargoes to load by Sea/Air/Rail/Road transportation from anywhere in India.
    C&F Agents For Export
    Sea C&f Agents
    Import Custom Clearing Agents
    Freight Forwarding Agencies For Sea
    Cargo Agents For Sea International
    Freight Forwarding Agencies For Air

    ReplyDelete
  46. This comment has been removed by the author.

    ReplyDelete

  47. Hey,
    Hope you are doing great in this uncertain time.
    Really Great Stuff ! especially like your comments around IT.
    (Web & App Development Company In USA, UK).


    You wrote amazing things about web development, But the market for app development is booming in the last few years.
    various technologies are coming into the market and many more.

    we request you to kindly write some blogs on Web Design & Mobile App
    Development Company In India



    For More Info: http://www.ecomsolver.com/
    Email: itecomsolver@gmail.com
    Contact Number: +91-8302699471
    Company’s Address 401 ,Big Benn Mall Okay Plus,B, Jaipur, Rajasthan 302019, India

    ReplyDelete
  48. I was looking for some information about an iOS App Developer and I should tell you that you have really wonderful article here. You put everything in detail and really easy and understandable.

    Visit:- Hire iOS App Developer in Singapore

    ReplyDelete
  49. Well to integrate a plugin for FB with the iOS one needs to know a few things before they are able to implement it successful. This tutorial guides on as to how we can install an FB plugin in an iOS app.

    At Hashstudioz we are helping businesses to cover the important segments of Mobile Application Development, IoT Application Development, Blockchain Application Development

    ReplyDelete
  50. This article is full of unique and great ideas! Thank you for sharing your experience. As a leading web and mobile application development company in New York, we are committed to providing customers with quality services. Please continue to update your website, because I am a regular visitor to your website. Here, I want to talk about RisingMax, which is the highest among IT Consulting Company in NYC. It provides real estate auction software that defines and creates innovative and powerful mobile app experiences, no matter how complex or diverse your needs are.

    ReplyDelete
  51. In this era we are surrounded by different technological amenities with all businesses having an online presence, you need secure and trustworthy cybersecurity solutions to keep it safe from any potential security threat.

    Breeze End Technology, LLC offer reliable and top-notch cybersecurity to help organizations fight cyber risks. We cover all aspects of cybersecurity to provide you with a complete range of services as our team is constantly on the verge of the latest advancements.

    We work with a comprehensive approach to keep your business safe from cyber threats. From cybersecurity program strategy to risk assessment, threat intelligence to security monitoring services, we have got a complete package for you. Our highly qualified and competent team knows how to fill in cybersecurity gaps to provide a clear road map for a powerful and strong cybersecurity system.

    Empowering you by Reliable Cyber Security Solutions, Email Security Services, Alert Logic Log Manager, Managed Data Security Offerings, Onsite & Remote Internet Security Services, Threat Manager with ActiveWatch, Web Security Manager: Trust the Security Experts, Website & Web Application Protection

    ReplyDelete
  52. Once again you provide several doses of reality which explore the complete explanation of packing and moving companies in Bangalore . This article don't have to be that long. I simply couldn't leave your web site before suggesting that I actually loved the usual info on packing and movers services in Bangalore. I just want to know what is the best way to get real service.

    ReplyDelete
  53. Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing.

    AWS Training in Hyderabad

    ReplyDelete
  54. SalesForce offers customizable charts and graphs so you can gain insight into the success of marketing tactics, lead conversions, sales staff productivity, and much more. Salesforce training in India

    ReplyDelete
  55. Awesonme content shared, keep writing and sharing such contents
    Data Science Training in Pune

    ReplyDelete
  56. Very elegantly composed post. A debt of gratitude is in order for sharing this, I truly like you setting aside the effort to impart to everybody…

    AI Training in Hyderabad

    ReplyDelete
  57. Very informative blog thank you for sharing.

    To make your career development the best by learning software courses by getting trained from the best software training institute in Chennai. Just select your fav... course given below.
    php course in chennai
    RPA Training in Chennai
    Azure Training in Chennai
    DevOps Training in Chennai
    Cloud-computing Training in Chennai
    Blue-Prsim Training in Chennai
    Ui-Path Training in Chennai

    ReplyDelete

  58. Nice blog thank you .For your Sharing It's a pleasure to read your post.It's full of information I'm looking for and I'd like to express that "The content of your post is awesome"
    C#.NET Training In Chennai
    hadoop training in chennai
    software testing training in chennai

    ReplyDelete

  59. Nice blog thank you .For your Sharing It's a pleasure to read your post.It's full of information I'm looking for and I'd like to express that "The content of your post is awesome"

    Aimore Tech is the Best Software training institute in chennai with 6+ years of experience. We are offering online and classroom Trainings.
    Dotnet Training in Chennai
    Core java Training in Chennai
    Web design Training in Chennai
    Node js Training in Chennai

    ReplyDelete
  60. Whatsapp Number Call us Now! 01537587949
    outsourcing in Bangladesh
    USA pone web iphone repair USA
    USA SEX WEB careful
    bd sex video B tex
    bd sex video sex video
    bd sex video freelancing course

    ReplyDelete
  61. They're produced by the very best degree developers who will be distinguished for your polo dress creation. You'll find Ron Lauren inside an exclusive array which includes particular classes for men, women.
    data science coaching in hyderabad

    ReplyDelete
  62. Just pure brilliance from you here. I have never expected something less than this from you and you have not disappointed me at all. I suppose you will keep the quality work going on.
    data science coaching in hyderabad

    ReplyDelete
  63. I want you to thank for your time of this wonderful read!!! I definitely enjoy every little bit of it and I have you bookmarked to check out new stuff of your blog a must read blog!
    data analytics course in hyderabad

    ReplyDelete
  64. İnsan böyle şeyler görünce mutlu oluyor

    ReplyDelete
  65. We are from a leading education providers company. Our course has been specially developed for students and professionals in the early stages of their careers who wish to pursue rewarding careers with Data Science. The course curriculum is well-designed so that even the most novice student can grasp the concepts in a simple manner.

    Check outhttps://www.careerera.com/data-science/certification-course/india/delhi

    ReplyDelete
  66. I will try some of these sites on this new blog commenting site List exactly what I look for. Telugu Mobile repair training center near me

    ReplyDelete
  67. "Thank you for providing valuable details about the best MEC colleges in Hyderabad!"
    Best Colleges For MEC In Hyderabad

    ReplyDelete
  68. Excellent information, I must say. Visiting your website is awesome and wonderful.I appreciate you giving this knowledge because I will find it beneficial.
    Best Colleges in Hyderabad For BBA


    ReplyDelete
  69. remember, The social integration of your program is strengthened by Facebook's SDK, enhancing user experiences. Happy programming!
    Data Analytics Courses in India

    ReplyDelete
  70. Hi,
    This post provides a clear and detailed guide on integrating Facebook functionality into an iOS app using the Facebook SDK. It covers all the necessary steps, from SDK installation to configuring the Xcode project and implementing various features like login and photo sharing. A valuable resource for iOS developers looking to leverage Facebook in their apps. Thank you for sharing.
    Data Analytics Courses in Nashik

    ReplyDelete
  71. Your ability to give a balanced viewpoint that takes into account other viewpoints and addresses potential problems stands out above all else. DevOps Course

    ReplyDelete
  72. Great........It's been a pleasure working with you.It's wonderful! Your post will remain in my thoughts.
    Best Colleges For BBA In Hyderabad

    ReplyDelete
  73. You have recently made some very outstanding contributions. Your breadth of knowledge, astute analysis, and lucidity of expression are admirable. Your knowledge enriches our conversations and offers priceless direction. Blue Prism Training

    ReplyDelete
  74. You have recently made some very outstanding contributions. Your breadth of knowledge, astute analysis, and lucidity of expression are admirable. Your knowledge enriches our conversations and offers priceless direction. Blue Prism Certification

    ReplyDelete
  75. This post provides a clear and detailed guide for integrating Facebook functionality into iOS apps using the Facebook SDK. The easy to follow instructions make it easy for developers to enable social sharing and login features seamlessly. Thank you for sharing your knowledge.
    Data Analytics Courses In Dubai

    ReplyDelete
  76. I must say, this information is excellent. It was fantastic and wonderful to visit your website. I appreciate you sharing this information with us since I will find it useful.
    Data Analytics Courses in Agra

    ReplyDelete
  77. This blog is a useful, up-to-date resource with interesting information. Check our IT Certification Course by SkillUp Online.

    ReplyDelete
  78. Thank you for your contribution to Software Development Company Florida, fostering growth, and enhancing the tech landscape. Your work is appreciated.

    ReplyDelete
  79. Your blog post on sharing content with Facebook from an iOS app is incredibly informative and timely.
    Digital marketing courses in illinois

    ReplyDelete
  80. Thank you for making it easier for users to share their app experiences with their social networks!"
    Digital Marketing Courses in Italy

    ReplyDelete
  81. RS organisation is a popular local SEO company in Noida sector 63 that works efficiently. Our efficient and reputed SEO solutions help you to rank your business website on top. We ensure quality website services for all our clients.

    ReplyDelete
  82. Kliff Technologies offers Digital Marketing services that help your business achieve its online goals. Services include website design, digital marketing, SEO, PPC and more. Digital Marketing Company in Vasant Vihar

    ReplyDelete
  83. really nice info for every one. we are providing best sap training in hyderabad and placements also this key word very useful for more info SAP Success Factors

    ReplyDelete
  84. This fantastic blog is extremely good and well enjoyed with incredible informative content which surely activates the learners to gain enough knowledge. Nice work.
    Data analytics framework

    ReplyDelete
  85. mind blowing content for learners to gain Knowledge please visit my site https://www.avinatech.com/

    ReplyDelete