Coder Social home page Coder Social logo

microsoft / embeddedsocial-ios-sdk Goto Github PK

View Code? Open in Web Editor NEW
19.0 7.0 15.0 21.25 MB

SDK for interacting with the Microsoft Embedded Social service from inside your iOS app

License: MIT License

Swift 98.05% Objective-C 0.03% Shell 0.11% Ruby 0.24% Liquid 1.57%

embeddedsocial-ios-sdk's Introduction

Microsoft Embedded Social

iOS SDK

This is an SDK that works with the Microsoft Embedded Social service to provide social networking functionality inside your iOS application.

Requirements

  • iOS 9.0+
  • Xcode 8.3+
  • Swift 3.2

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods [--pre]

CocoaPods 1.4.0+ is required to build EmbeddedSocial SDK.

To integrate EmbeddedSocial SDK into your Xcode project using CocoaPods, specify it in your Podfile:

target '<Your Target Name>' do
  use_frameworks!

  pod 'EmbeddedSocial', :git => 'https://github.com/Microsoft/EmbeddedSocial-iOS-SDK.git', :branch => 'develop', :submodules => true
  
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
    	target.build_configurations.each do |config|
        	config.build_settings['SWIFT_VERSION'] = ‘3.2
        end
    end
end

Then, run the following command:

$ pod install

Usage

Info.plist

Insert the following lines in your Info.plist file in your project:

<key>LSApplicationQueriesSchemes</key>
<array>
	<string>fbapi</string>
	<string>fb-messenger-api</string>
	<string>fbauth2</string>
	<string>fbshareextension</string>
	<string>twitter</string>
	<string>twitterauth</string>
</array>

For Sign In functionality works, you should register your Application Bundle Identifier in:

After your Application registered, you will receive API keys. You should insert following lines in your Info.plist file:

<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleURLSchemes</key>
		<array>
			<string> *YOUR FB APP KEY* </string>
		</array>
	</dict>
	<dict>
		<key>CFBundleURLSchemes</key>
		<array>
			<string> *YOUR TWITTER APP KEY* </string>
		</array>
	</dict>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>Editor</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string> *YOUR GOOGLE APP KEY* </string>
		</array>
	</dict>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>Editor</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
		</array>
	</dict>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLName</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string> *YOUR MICROSOFT APP KEY* </string>
      <string>auth</string>
      </array>
  </dict>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>embeddedsocial</string>
    </array>
  </dict>
</array>

AppDelegate.swift

Please, insert the following lines in your AppDelegate.swift file.

For SDK initialization:

func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
             
    let args = LaunchArguments(app: application,
                               window: window!,
                               launchOptions: launchOptions ?? [:],
                               menuHandler: SideMenuItemsProvider,
                               menuConfiguration: .tab)
    SocialPlus.shared.start(launchArguments: args)

    return true
}

For URL shemes handling:

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
    return SocialPlus.shared.application(app, open: url, options: options)
}

For Push Notifications handling:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)})
    SocialPlus.shared.updateDeviceToken(devictToken: deviceTokenString)
}

func application(_ application: UIApplication, didReceiveRemoteNotification data: [AnyHashable : Any]) {
    SocialPlus.shared.didReceiveRemoteNotification(data: data)
}

Advanced Usage

Menu

Menu Types

You can implement on of three menu types provided by SideMenuType:

public enum SideMenuType {
    case tab, dual, single
}

You can specify this in AppDelegate.swift with menuConfiguration parameter in LaunchArguments. For example:

let args = LaunchArguments(..., menuConfiguration: .tab | .dual | .single)

Menu Handler

You can implement your own menu items. You should make implementation for SideMenuItemsProvider:

public protocol SideMenuItemsProvider: class {
    func numberOfItems() -> Int
    func image(forItem index: Int) -> UIImage
    func imageHighlighted(forItem index: Int) -> UIImage
    func title(forItem index: Int) -> String
    func destination(forItem index: Int) -> UIViewController
}

You can handle this in AppDelegate.swift with menuHandler parameter in LaunchArguments. For example:

let menu: SideMenuItemsProvider = MyMenuImplementation()
let args = LaunchArguments(..., menuHandler: menu , ...)

Example

If you will have problems with SDK implementation, please, follow the Example Application.

License

By using this code, you agree to the Developer Code of Conduct, and the License Terms.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

embeddedsocial-ios-sdk's People

Contributors

eugene-shcherbinock avatar igorpopov-ms avatar jaroslawromanovich avatar mrdevms avatar msftgits avatar oboje avatar sharadagarwal avatar vadim-bulavin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

embeddedsocial-ios-sdk's Issues

Performance: investigate application start time

Please use this article as a reference https://habrahabr.ru/post/317650/.

Also we must change our workspace setup: currently we have our SDK and Example project as different targets of same project. As a result, we have to compile all CocoaPods twice: once for each target. The solution is to separate the Example project and SDK into two xcodeprojects under one workspace.

My Profile: Popular post feed displaying only first page of posts

  1. Open My Profile
  2. Open Popular posts feed
  3. Scroll the posts feed down and note posts that are loaded once you reaching the end of currently loaded page

Current result:
Each time the end of a page reached posts are loaded from the first page, i.e. feed continuously cycling over the first page, since it doesn't send cursor and limit query string arguments to the server

Move custom code outside of Swagger-generated lib

Please move the code that modifies base path into APISettings class.

open class EmbeddedSocialClientAPI {
    private static var _basePath = "https://api.embeddedsocial.microsoft.com"
    open static var basePath: String {
        set {
            _basePath = newValue
        }
        get {
            if let path = getEnvironmentVariable("EmbeddedSocial_MOCK_SERVER") {
                return path
            } else {
                return _basePath
            }
        }
    }
    open static var credential: URLCredential?
    open static var customHeaders: [String:String] = [:]
    static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
}

Users List: disable ability to follow current user

  1. Open Home
  2. Open user_1 profile, where user_1 != current_user. Current_user follows user_1.
  3. Open followers screen

Expected: current user's profile doesn't have 'follow' button
Actual: current user's profile has 'follow' button

Rename project

Use EmbeddedSocial name for project (instead of MSGP) and bundle com.microsoft.embeddedsocial

Profile: Issue with following/follower numbers for topic author

  1. Open topic's author profile from home screen (i used Vadim Bulavin topic)
  2. See that there are 2 followers/2 following
  3. Open followers - there is only 1 person in the list
  4. Unfollow Vadim and return back to profile

Actual - numbers are the same, and status is following
Expected - numbers should be changed as well as status

Home: Incorrect flow of posts loading

Currently posts on the Home screen are loaded as follows:

  • Once opened first page is loaded
  • Next pages are loaded on "pull to refresh" action and new posts are added to the top of the page
  • Nothing happens in case feed scrolled down to the bottom

This seems to be incorrect and correct flow should be like follows:

  • Once opened first page is loaded
  • In case page scrolled to the bottom a next page should be loaded and added to the bottom of the feed (aka infinite scrolling)
  • On "pull to refresh" all posts should be removed and should be loaded again from the first page

Navigation: home screen is not opened after new account has been created

  1. Fresh install the app
  2. Open Sign In screen
  3. Log into social account that is not registered in the app
  4. Fill in info on Create Account screen
  5. Tap 'Submit'

Expected: Home screen is opened and menu points are updated
Actual: Nothing happens

Additional note: the issue is located somewhere in CrossModuleCoordinator.onSessionCreated method.

Performance: Image compression

  1. Implement async image compression service.
  2. Define requirements for max pixel resolution.
  3. Define requirements for max size in bytes.
  4. Replace code similar to the sample below with calls to image compression service.
guard let imageData = UIImageJPEGRepresentation(image, 0.8) else {
    return
}

My Profile: Wrong posts feed in Recent Posts

  1. Make sure that some topics are available in the /topics feed and in /users/{UserHandle}/topics feed
  2. Open My Profile
  3. Check posts in the Recent Posts lists
  4. Scroll down the list
  5. Check what posts are loaded while scrolling down the list

Current result:
Once My Profile opened Recent Posts section displays 1st page from /topics feed, but while scrolling down next pages are loaded from /users/{UserHandle}/topics feed

Also note that on pull to refresh Recent Posts section displays posts from /users/{UserHandle}/topics starting from the 1st page

Home: Implement topic menu

Topics menu should consists of 4 items for Home:
Follow/Unfollow (depends on User state)
Block User
Report User
Hide Post (available only for home view, for rest of other feeds should be removed, like popular, etc)

For your own posts is should consist of 2 items:
Edit Post
Remove Post

Follow user: error 403 is returned when trying to follow a public profile

Request details:

POST /v0.6/users/me/followers HTTP/1.1
Host: ppe.embeddedsocial.microsoft.com
Authorization: Facebook AK=ec1665a4-920d-4449-b8a0-49ed374d4290|TK=EAAVXZAYQYTB8BAEGm5qBuZBsZAlhQFEmOtGkXrvelvK7lQeGnNsmSri8lRZBXjlCdfZBl5YrZCHI3jQA5ekESSRhIOd3jlBtWo3Hptc0AjuFmuzcoGms8444xOkYKZC2kRgGzN2NVgqhpTtbI1Oy4O3mu7mvB9Ur5V5SwOjtZC6U8Fhe8mSlfy1tjTuyCfxzRXmjbn4ZBJqIqJn9pWZBz468Aouq3o94XjlfcZBVpbyuuxjMgZDZD
Content-Type: application/json
Cache-Control: no-cache

{
  "userHandle": "3vJemCygjU_"
}

Home: Number of post comments is not displayed

  1. Make sure there is at least one post in the API response with one or more comments
  2. Open Home screen
  3. Check details of the post mentioned above

Current result:
Number of comments is not displayed, i.e. set to 0

Note: It looks like currently comments counter displays number of likes instead, so make sure that the post doesn't have likes before testing

Localization: move all strings into localization files. Make sure all strings in the code are localized

Motivation: We haven't agreed on localized strings usage so far. They appear in project in 3 different ways: localization file, two files with constants, just hardcoded both with and without localization macros.

  1. Let's move all strings into localization file and use SwiftGen to create constants out of it. All of the strings must be update with new approach.

  2. Create convenience category that would provide following syntax for localizing strings:
    label.title = "Some title".localized

  3. Localization file must follow a convention: <module>.<element>.<string_key>

Examples:

user-profile.button.follow
user-profile.header.full-name-placeholder

Home: Feed request failed

Feed request failed if you build app from different branches.

Steps to reproduce

  1. checkout 1 branch
  2. build app and run it
  3. perform sign-in
  4. verify that home works
  5. checkout another branch, for example develop
  6. feed faired an error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.