Just a quick note on How to use ShareKit open source library a little bit better.
0. Settings for Social Networks
Getting ShareKit first time you need to setup social networks. Nothing difficult because it has so good commented guide in
SHKConfig file. I use Git and made
a public fork of ShareKit for the Alteprlay. So now when I push back changed code of ShareKit as a submodule every one can see it. And my settings also
Despite that a solution is so obvious I still want to share it because it could save you hours to cut your private settings from public Github commits.
Just copy SHKConfig.h file from the lib directory to your source files and remove original one from the project. Then do anything you want with settings and it will always be in your private repository.
1. Activate URL Sharers for text sharing
In the Forismatic app we need to share quotes via Google Reader and make possible to copy quote to the Pasterboard. Both features are disabled by default.
There are several boolean methods in SHKSharer that control whether a derived Sharer can share Text, URL, Image or File. So we can find +(BOOL)canShareText and return YES instead NO. It just works.
Each time you update ShareKit library not depending you use Git or whatever you need to change this parameters again and again. So the right suggestion is Obj-c Categories. Example for Google Reader:
The same way you can deny or allow any service for any content.
3. Support both localization for the target app and ShareKit
An app may have only one active Localizable.strings for each language. ShareKit provides localizations so it has many such strings.
Again, in the Forismatic app we have own localizations and own *.strings. I was surprised when found they compete with ShareKit translation strings. The active one is that one which is last added
The simplest solution is just copy those translation content you need to your *.strings and it’ll work. But again it’ll be hard to manage updates, etc. So I suggest more accurate solution.
- Rename all ShareKit’s localizations to LocalizableShareKit.strings
- Find SHK.m and change NSLocalizedString(key, key) to NSLocalizedStringFromTable(key, @”LocalizableShareKit”, key)
So now it doesn’t compete with your own localizations and gets translations from renamed *.strings.
Don’t forget to push it back to your fork and merge in right way each time you update the lib.
4. Next big thing
The next thing I want implement is to change sharing text depending on which Sharer call it. For example,
- if it’s Email Sharer I want to attach AppStore link after a quote
- if it’s Twitter Sharer it may vary of how long a text quote because twitter can contain 140 chars only. So if it’s more than 140 then it’s better to cut the quote and attach a link to this quote.
- etc.