Search code examples
blackberry-webworksblackberry-10

BlackBerry WebWorks to invoke popping BB10 Share panel/screen


How can u get my webworks app to pop open the blackberry 10 share panel?

Ex: open a website in the browser, click the overflow button and then click share

Thank you!


Solution

  • You'll want to look at the invokeTargetPicker API.

    Essentially, you create a request

    var request = {
      action: 'bb.action.SHARE',
    
      // for a file
      uri: 'file://' + path,
    
      // for text you'd use 'data'
      data: 'I am awesome',
    
      target_type: ["APPLICATION", "VIEWER", "CARD"]
    };
    

    Then you call the API

    blackberry.invoke.card.invokeTargetPicker(request, "Your Title",
    
        // success callback
        function() {
            console.log('success');
        },
    
        // error callback
        function(e) {
            console.log('error: ' + e);
        }
    );
    

    API Documentation is available here: https://developer.blackberry.com/html5/apis/blackberry.invoke.card.html#.invokeTargetPicker

    I wrote a sample app, which you can test out on our GitHub repo: https://github.com/ctetreault/BB10-WebWorks-Samples/tree/master/ShareTargets