Sharemotion, is a lightweight gem for RubyMotion. It provides functions to share text, urls,… on social networks or messages. If you need a full featured library you should use ShareKit.
Loot at the rakefile and the demo app for fast example
- Add facebook plist informations (Rakefile)
app.info_plist['CFBundleURLTypes'] = [{'CFBundleURLSchemes' => ['fbxxxxxxxxxxxxx']}]
app.info_plist['FacebookAppID'] = "xxxxxxxxxxxxx"
- Add facebook sdk through pods (Rakefile)
app.pods do
pod 'Facebook-iOS-SDK'
end
- Add frameworks (Rakefile)
app.frameworks += ['MessageUI', 'Twitter']
-
gem install sharemotion
-
require 'sharemotion' (Rakefile)
# create the item you want to share
# the basic item can have :title, :url, image(string url), :text, you can override the hash for each sharers
# some sharers have specific fields and some won't use all the base fields, described later
@item = Sharemotion::Item.new({
:title => "Look at that bro!",
:url => "http://www.google.fr",
:image => "http://www.aujardin.ch/photos/tulipe1.jpg",
:text => "You should watch this site, it's incredible",
:sharers => {
:email => {
:to => ["[email protected]", "[email protected]"],
:text => "Well you shouldn't..."
},
:facebook => {
:caption => "OHAI",
:title => "HEY HEY"
}
}
})
# define sharers you want to use
# you can override the title of the sharer with a block
facebook = Sharemotion::SHMFacebook.alloc.initWithItem(@item) {|sharer|
sharer.sharer_title = "Bookface"
}
sharers = [
Sharemotion::SHMEmail.alloc.initWithItem(@item),
Sharemotion::SHMSms.alloc.initWithItem(@item),
Sharemotion::SHMTwitter.alloc.initWithItem(@item),
facebook
]
# Init the UIActionSheet with your sharers and display it
@sheet = Sharemotion::Sheet.alloc.initWithSharers(sharers, controller:self)
@sheet.showInView(self.view)
# You can also use a sharer directly
facebook = Sharemotion::SHMFacebook.alloc.initWithItem(@item)
facebook.share(self)
-
SHMEmail will use :text(string), :title(string), :html(boolean), :cc(array), :bcc(array), :to(array)
-
SHMFacebook will use :url(string), :image(string), :caption(string), :title(string), :text(string)
-
SHMSms will use :text(string), to(array)
-
SHMtwitter will use :text(string), :url(string)
As you can see email and sms accept :to, however, email wants… emails and sms wants phonenumbers so if you want to use both of them with right data you have to use the override hash explained before :
@item = Sharemotion::Item.new({
:title => "Look at that bro!",
:url => "http://www.google.fr",
:image => "http://www.aujardin.ch/photos/tulipe1.jpg",
:text => "You should watch this site, it's incredible",
:sharers => {
:email => {
:to => ["[email protected]", "[email protected]"],
},
:sms => {
:to => ["06XXXXXXXX", "07XXXXXXXX"]
}
}
})
Better documentation
More tests
More sharers
Twitter < IOS 5.0
Do not require Facebook SDK if you don't use Facebook sharer
Same for frameworks