2

As the title says, I'm trying to invoke Contacts in BlackBerry Cascades:

https://developer.blackberry.com/cascades/documentation/device_platform/invocation/contacts.html

with fields filled from string variable containing a vCard. I have had no success with mimeTypes, URIs, actions and targets specified in above documentation. The following code or any variation I could develop from documented cases doesn't invoke:

    Container {
    property string inputString //contains data from which vCard should be extracted if detected
    //....
    attachedObjects: [
            Invocation {
                id: myQuery
                property bool ready: false
                query {
                    mimeType: "text/plain"
                    invokeTargetId: "sys.browser"
                    uri: ("http://www.google.com/search?q="+ escape(inputString))
                    invokeActionId: "bb.action.OPEN"
                    data: ""
                    onArmed: {myQuery.ready = true}
                    onQueryChanged: {
                        myQuery.query.updateQuery()
                    }
                }
        }
    //....
     if (inputString.indexOf("VCARD") > -1) {
            myInvocation.query.setMimeType("");
            myInvocation.query.setUri(inputString);
            myInvocation.query.setData(inputString);
            myInvocation.query.setInvokeTargetId("sys.pim.contacts.card.viewer");
            myInvocation.query.setInvokeActionId("bb.action.VIEW");
            myInvocation.query.updateQuery();
    }
     //...
     Button {
     onClicked: {
                if (myQuery.ready = true) {
                    myQuery.trigger(myQuery.query.invokeActionId);
                }

            }
            }
      }

Other invocations like SMS, eMail & Browser do invoke with this setup, although the MimeType, URIs, data, targets and actions took some fiddling to set right and the configuration that finally worked is not the one from the documentation.

So, how to invoke Contacts?

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44

1 Answers1

0

I've modified your code so now you'll be able to launch as the browser app (as in the code you provided) as the contact app. I don't have any contact set up on my dev device, so in order to view a certain contact you need to provide respective contact ID (see ContactService for information on this) and so on

import bb.cascades 1.0

Page {
    Container {
        property string inputString //contains data from which vCard should be extracted if detected
        //....

        Button {
            text: "..."
            onClicked: {
                myQuery.trigger(myQuery.query.invokeActionId);  // launches browser
                contactInvocation.trigger(contactInvocation.query.invokeActionId);  // launches contacts
            }
        }
        attachedObjects: [
            Invocation {
                id: myQuery
                query {
                    mimeType: "text/plain"
                    invokeTargetId: "sys.browser"
                    uri: ("http://www.google.com/search?q=" + escape("sample"))
                    invokeActionId: "bb.action.OPEN"
                    onQueryChanged: {
                        myQuery.query.updateQuery()
                    }
                }
            },
            Invocation {
                id: contactInvocation
                query {
                    invokeTargetId: "sys.pim.contacts.app"
                    mimeType: "application/vnd.blackberry.contact.id"
                    invokeActionId: "bb.action.OPEN"
                    onQueryChanged: {
                        contactInvocation.query.updateQuery()
                    }
                }
            }
        ]
    }
}
Sunseeker
  • 1,503
  • 9
  • 21