Skip to content
SocialHub is multi SNS client for Java and Objective-C (with J2ObjC)
Java Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
gradle/wrapper
src
tool
.gitignore
.travis.yml
LICENSE
README.md
build.gradle
gradlew
gradlew.bat
j2objc.gradle
j2objc.sh
local.properties
prefixes.properties
settings.gradle

README.md

SocialHub Build Status

SocialHub is a multi social network service's API library written in Java, and can be complied to Objective-C by J2ObjC. and we can also use it with Kotlin and Swift too.

List of SNS

Available

Future Works

Most of all libraries are modified (remove complex dependency and unused functions in SocialHub) for compilation to Objective-C with J2ObjC.

Detail Documents

See Detail Documents

Code Sample

Authorization

Code sample to authorize account and get account information.

/* JAVA */
// 1. Make Authorized Account Object

// For Twitter
TwitterAuth auth = SocialHub.getTwitterAuth(CONSUMER_KEY, CONSUMER_SECRET);
Account account = auth.getAccountWithAccessToken(ACCESS_TOKEN, ACCESS_SECRET);

// For Mastodon
MastodonAuth auth = SocialHub.getMastodonAuth(HOST);
Account account = auth.getAccountWithAccessToken(ACCESS_TOKEN);


// 2. Request To SNS (all sns same interface)
User user = account.action().getUserMe();
System.out.println(user.getName());

Group Timeline

Code sample to get unified timeline comments from account group (two or more accounts).

/* JAVA */
// 1. Make Account Group
AccountGroup accounts = new AccountGroup();
accounts.addAccount((Account) twitterAccount);
accounts.addAccount((Account) mastodonAccount);

// 2. Get Home New Timeline
CommentGroup comments = accounts.action().getHomeTimeLine();

// 3. Get Past Timeline
CommentGroup pasts = comments.action().getPastComments();

if you want more samples, please see detail documents and test code.

J2ObjC

J2ObjC is project aim to compile Java code to Objective-C code. SocialHub is adapted with J2ObjC compilation So, you can use SocialHub as an Objective-C library (also use in Swift) in MacOS or iOS application development. Travis CI compiles SocialHub and make SocialHub CocoaPods Repository. It's easy way to use this repository rather than compiling yourself.

Compile to Objective-C

To compile SocialHub to Objective-C framework, do following instructions. It's only executable on MacOS environment (This file is script of followings.)

  1. Download latest J2ObjC builds and unzip

    See: https://github.com/google/j2objc/releases

  2. Set J2ObjC path in local.properties file

    j2objc.home=${PATH}
  3. Build Objective-C libraries

    Build commands is written in j2objc.sh file. so execute it or do following commands. j2objc.gradle is gradle settings to make Objective-C library.

    ./gradlew -b j2objc.gradle clean :j2objcAssemble -x test
  4. Add dependency in your project

    After J2ObjC comple, cocoapod.spec will be created in ./build/j2objcOutputs folder, so you write SocialHub dependency in your CocoaPods project's Podfile like

    def j2objc_socialhub
        pod 'j2objc-SocialHub-debug', :configuration => ['Debug'], :path => '../shared/build/j2objcOutputs'
        pod 'j2objc-SocialHub-release', :configuration => ['Release'], :path => '../shared/build/j2objcOutputs'
    end
    
        ...
        NOTE: this line must be added manually for the relevant targets:
        j2objc_socialhub
        ...
    
  5. Use SocialHub in Swift

    Make bridging header, and write as following.

    #include "SocialHubHeader.h"
    

License

Author: @U_Akihir0

MIT

You can’t perform that action at this time.