Friday, September 20, 2013

Sharing on Facebook, Twitter with BB10 Cascades app

I am currently adding sharing feature to my BB10 Audiobook Reader app. I wanted to allow sharing on Facebook, Twitter, BBM  and other supported platform.

BB10 support this via Invocation framework, Using Invocation framework you can share things using native application.

Using Invokation Framework is easy, you just need use InvokeActionItem and set some property and all is done.

Following is my code that share comment via Facebook or Twitter. Following code will allow to share using any application which support plain text invocation target.

By default it will also have sharing icon, you can use Image property to change it to custom icon.

Pressing share button on toolbar will show all application which can share the data specified by mimeType, User can select one of those and share data using that application.

Page {
    ...
    actions[
        InvokeActionItem {
            title: "Share"
            query {
                mimeType: "text/plain"           
                invokeActionId: "bb.action.SHARE"
            }
            onTriggered: {
                data = "Comments to share";
            }
        }
        ...
    ]
    ...
}
You can find more about, how to share with individual application from here. And here is documentation for InvokeActionItem.

Here is how it looks and works on device.




2 comments:

  1. Hi,
    how to add facebook,gmail, twitter, linkedin to the share menu..in my share menu these are not coming

    ReplyDelete
  2. I have those application on device and also logged in with valid account in those application

    ReplyDelete