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

Web and WebWorks Development

Reply
New Contributor
Posts: 6
Registered: ‎06-10-2013
My Device: blackberry z-10,q10
My Carrier: Vodafone
Accepted Solution

Share data using BBM between my application on two blackberry Z10 devices

Hi,

I want to share some data between my application on two blackberry Z10 devices using BBM. The data sent from one end via BBM  should be received at the other end inside my application. How do I go about with this? 

BlackBerry Development Advisor
Posts: 15,513
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Share data using BBM between my application on two blackberry Z10 devices

There isn't a way to do this directly without the users taking some actions.

 

You can invoke BBM with a file with a custom extension to share.  The recipient will need to accept the file transfer and save the file.  Then they can click on the file icon in the BBM chat and your application can be invoked.

 

The bucketlist sample application does this if you'd like to see what that looks like.  

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
New Contributor
Posts: 6
Registered: ‎06-10-2013
My Device: blackberry z-10,q10
My Carrier: Vodafone

Re: Share data using BBM between my application on two blackberry Z10 devices

Thank you for replying but I need to do this using blackberry 10 webworks and not cascades. Is there any way to do it using webworks?
BlackBerry Development Advisor
Posts: 15,513
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Share data using BBM between my application on two blackberry Z10 devices

Yes, this can also be done using WebWorks.  The same invocation features are available to WebWorks applications. You can read about invocation and WebWorks here:

 

Invocation framework

 

The Cascades sample was just provided as an example to demonstrate the workflow.  Have a look and let me know if you have any futher 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
New Contributor
Posts: 6
Registered: ‎06-10-2013
My Device: blackberry z-10,q10
My Carrier: Vodafone

Re: Share data using BBM between my application on two blackberry Z10 devices

If I am not getting it wrong, I need to save my app data by creating a file like for instance a .txt file and then send it through BBM to other user and the user will have to download the file so that my app can use the data. I tried creating a .txt file but somehow I am getting an error NOT_FOUND_ERR. Below is the code using which I am trying to create and write to the file.

 

<script type="text/javascript">
document.addEventListener('webworksready', function(e) {
writeFile();
}, false);
function writeFile() {
// un-sandbox file system to access shared folder
blackberry.io.sandbox = false;

window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;

window.requestFileSystem(window.PERSISTENT, 1024 * 1024,
function (fs) {
// in order to access the shared folder,
// config.xml must declare the "access_shared" permission
// reference file by absolute path since file system is un-sandboxed
alert("File"+blackberry.io.sharedFolder);
fs.root.getFile(blackberry.io.sharedFolder+'misc/log1.txt', {create: true},
function (fileEntry) {
alert("FileEntry");
fileEntry.createWriter(function(filewriter){
var blob = new Blob(['helo'], {type: 'plain/text'});
filewriter.write(blob);
fileWriter.onwriteend = function(e) {
alert('Write completed.');
};
},errorHandler);
}, errorHandler);
});
}

function errorHandler(e) {
var msg = '';

switch (e.code) {
case FileError.QUOTA_EXCEEDED_ERR:
msg = 'QUOTA_EXCEEDED_ERR';
break;
case FileError.NOT_FOUND_ERR:
msg = 'NOT_FOUND_ERR';
break;
case FileError.SECURITY_ERR:
msg = 'SECURITY_ERR';
break;
case FileError.INVALID_MODIFICATION_ERR:
msg = 'INVALID_MODIFICATION_ERR';
break;
case FileError.INVALID_STATE_ERR:
msg = 'INVALID_STATE_ERR';
break;
default:
msg = 'Unknown Error';
break;
};

console.log('Error: ' + msg);
}
</script>

 

I have included <feature id="blackberry.io" /> & <rimSmiley Tongueermit>access_shared</rimSmiley Tongueermit> in my config.xml . Please reply.

Highlighted
BlackBerry Development Advisor
Posts: 15,513
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Share data using BBM between my application on two blackberry Z10 devices

[ Edited ]

You are missing a slash before misc on this line:

 

fs.root.getFile(blackberry.io.sharedFolder+'misc/log1.txt', {create: true},

 It should be:

 

fs.root.getFile(blackberry.io.sharedFolder+'/misc/log1.txt', {create: true},

 

But note that you can also store the file in  the data directory of your application's sandbox.  It doesn't have to be stored in the public, shared area.

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
New Contributor
Posts: 6
Registered: ‎06-10-2013
My Device: blackberry z-10,q10
My Carrier: Vodafone

Re: Share data using BBM between my application on two blackberry Z10 devices

Hi,

Now that Webworks 2.0 beta SDK is available, is it possible to share data from my application on a Z10 device  and receive the shared data  inside my app on another Z10 device using BBM?

BlackBerry Development Advisor
Posts: 15,513
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Share data using BBM between my application on two blackberry Z10 devices

The WebWorks 2.0 SDK didn't add any new features for integrating with BBM.  The solution above is still the only one for sharing data between devices over BBM.

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