Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
shahriyarali
Posts: 25
Registered: ‎05-22-2012
My Device: any BB10 released
My Carrier: Airtel
Accepted Solution

Sharing files over BBM [amateur]

Hey! Before i start let me clear that i've used, gone  through all invocation related samples & yes still can't figure out how to share a particular file to BBM contacts with just one button.

 

I'm trying to build an app of sounds & it's gonna be a simple list view with preview, send options. Can someone help sharing these attached sounds over to BBM contacts?

 

About me, a startup developer and know little bit of QML. nothing else. So more of QML is appreciated.

Please use plain text.
Administrator
MSohm
Posts: 14,314
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Sharing files over BBM [amateur]

There is a QML sample on how to share an image over BBM in my blog post here:  Using the Invocation Framework with BlackBerry Messenger

 

Have a look and let me know if you have any questions.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Contributor
shahriyarali
Posts: 25
Registered: ‎05-22-2012
My Device: any BB10 released
My Carrier: Airtel

Re: Sharing files over BBM [amateur]

[ Edited ]

thanks mark! that really helped me understand more about invocation. but a quick question, can't i place a normal button to imply invocation? i dont need actionitems as shown in the tutorial. this is the code i'm typing and i get NFC sharing page instead of BBM contacts 

 

Button {
                id: share
                text: "Share"
                onClicked: {
                    mimeType:
                    "text/plain"
                    invokeQuery.uri = "sys.bbm.sharehandler"
                    //invokeQuery.uri = "bb.action.SHARE"
                    data:
                    "This is some text to share."
                    invokeQuery.updateQuery();
                }
                attachedObjects: [
                    Invocation {
                    id: invokeShare
                    query {
                        InvokeQuery {
                            id: invokeQuery
                        }
                    }
                    onArmed: {
                        trigger("bb.action.SHARE");

                    }
                }
                ]
            }

 

 

thanks again. appreciate your help

Please use plain text.
Administrator
MSohm
Posts: 14,314
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Sharing files over BBM [amateur]

You're close.  Here's what you need to do.

 

Button {
    id: share
    text: "Share"
    onClicked: {
        invokeQuery.data =  "This is some text to share."
        invokeQuery.updateQuery();
        invokeShare.trigger("bb.action.SHARE");
    }
    attachedObjects: [
        Invocation {
            id: invokeShare
            query {
                InvokeQuery {
                    id: invokeQuery
                    mimeType: "text/plain"
                    invokeTargetId: "sys.bbm.sharehandler"
                    onQueryChanged: invokeShare.query.updateQuery()
                }
            }
        }
    ]
}

 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Contributor
shahriyarali
Posts: 25
Registered: ‎05-22-2012
My Device: any BB10 released
My Carrier: Airtel

Re: Sharing files over BBM [amateur]

works great! thanks mark. appreciate your quick help :smileyhappy:

Please use plain text.
Contributor
shahriyarali
Posts: 25
Registered: ‎05-22-2012
My Device: any BB10 released
My Carrier: Airtel

Re: Sharing files over BBM [amateur]

[ Edited ]

last problem, how do you link a file to this button? below is the code i'm applying & button fails to create any action. i've read people going onto C++ for such events. Can't it be done over QML codes? thanks

 

Button {
                id: share
                text: "Share"
                onClicked: {
                    invokeQuery.uri = "file:///app/native/assets/test.png"
                    invokeQuery.updateQuery();
                    invokeShare.trigger("bb.action.SHARE");
                }
                attachedObjects: [
                    Invocation {
                        id: invokeShare
                        query {
                            InvokeQuery {
                                id: invokeQuery
                                //mimeType: "text/plain"
                                invokeTargetId: "sys.bbm.sharehandler"
                                onQueryChanged: invokeShare.query.updateQuery()
                            }
                        }
                    }
                ]
            }

 

Please use plain text.
Administrator
MSohm
Posts: 14,314
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Sharing files over BBM [amateur]

If the user is selecting the file you can use a Filepicker.  If this is a file referenced from your app you'll need to go down into C++ to get the current directory (assuming you want to use a file installed with your app like your example).

 

QString path = QDir::current().absoluteFilePath("assets/test.png");

 The code above would get you the full path to the file used in your example.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Contributor
shahriyarali
Posts: 25
Registered: ‎05-22-2012
My Device: any BB10 released
My Carrier: Airtel

Re: Sharing files over BBM [amateur]

and where should i put this? lol sorry man this is my thrid app and first to get this feature. Once this is done, i'm ready to roll :smileywink:

Please use plain text.
Administrator
MSohm
Posts: 14,314
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Sharing files over BBM [amateur]

You'll need to create a C++ class that you can integrate with QML.  Have a look at this page in the docs for details on how to connect the two.

 

C++ and QML integration

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.