Using Invoke APIs in your BlackBerry widget

Tips and Tricks

One feature of Super Apps is that they integrate with the native applications on BlackBerry® smartphones. So, how do you go about doing this? For BlackBerry® Widgets, it’s actually pretty simple. The BlackBerry® Widget API provides the Invoke object, which allows you to design your application to seamlessly work with the other applications on the BlackBerry smartphone. This results in a richer BlackBerry smartphone user experience.

By leveraging the Invoke API, you can invoke virtually any other application on the BlackBerry smartphone through a simple API call, where you’ll set a parameter for the app you want to invoke and then pass in any parameters that application is expecting. Right out of the box, the BlackBerry API contains these APIs to invoke:

Address Book

<script type="text/javascript">
var contact = new blackberry.pim.Contact();
contact.firstName = 'Joe';
contact.lastName = 'Smith';

var args = new blackberry.invoke.AddressBookArguments(contact);
args.view = 0;

blackberry.invoke.invoke(blackberry.invoke.APP_ADDRESSBOOK, args);
</script>

BlackBerry Browser

<script type="text/javascript">
var args = new blackberry.invoke.BrowserArguments('http://www.blackberry.com');
blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);
</script>

Calendar

<script type="text/javascript">
var appt = new blackberry.pim.Appointment();
appt.summary = 'Get Together For lunch';

var args = new blackberry.invoke.CalendarArguments(appt);
args.view = 0;

blackberry.invoke.invoke(blackberry.invoke.APP_CALENDAR, args);  // Calendar
</script>

Camera

<script type="text/javascript">

var args = new blackberry.invoke.CameraArguments();
args.view = 1; // Video Recorder

blackberry.invoke.invoke(blackberry.invoke.APP_CAMERA, args);  // Video Recorder Application
</script>

Maps

<script type="text/javascript">
var args = new blackberry.invoke.MapsArguments(43.26, -80.30);
blackberry.invoke.invoke(blackberry.invoke.APP_MAPS, args);
</script>

MemoPad

<script type="text/javascript">
var memo = new blackberry.pim.Memo();
memo.title = 'Oranges I like';
memo.note = 'navel';

var args = new blackberry.invoke.MemoArguments(memo);
args.view = 0; // New

blackberry.invoke.invoke(blackberry.invoke.APP_MEMOPAD, args);  // Memo Pad
</script>

Email

<script type="text/javascript">

var args = new blackberry.invoke.MessageArguments('foo@domain.com', 'hello', 'world');
args.view = blackberry.invoke.MessageArguments.VIEW_NEW; // New

blackberry.invoke.invoke(blackberry.invoke.APP_MESSAGES, args);  // New Message
</script>

Phone

<script type="text/javascript">

var args = new blackberry.invoke.PhoneArguments('555-555-5555', true);
args.view = blackberry.invoke.PhoneArguments.VIEW_CALL;

blackberry.invoke.invoke(blackberry.invoke.APP_PHONE, args);
</script>

Search

<script type="text/javascript">
var args = new blackberry.invoke.SearchArguments('build', 'Joe');
blackberry.invoke.invoke(blackberry.invoke.APP_SEARCH, args);  // Search
</script>

Tasks

<script type="text/javascript">
var task= new blackberry.pim.Task();
task.summary = 'Pick up Milk';

var args = new blackberry.invoke.TaskArguments(task);
args.view = 0;

blackberry.invoke.invoke(blackberry.invoke.APP_TASKS, args);
</script>

Any other Java application on the device

<script type="text/javascript">

var args = new blackberry.invoke.JavaArguments('net_rim_bb_memo_app');
blackberry.invoke.invoke(blackberry.invoke.APP_JAVA, args);  // Java

</script>

By leveraging these APIs, you can come up with a compelling user story or use case to design your application as a one-stop shop for anyone looking to organize their daily tasks through your app. Open an email, save a meeting invite, set GPS to locate the meeting room, associate tasks with that meeting – these are just a few of the countless ways you can easily leverage the Invoke APIs, taking your BlackBerry Widget to the next level and embracing the Super App concept!

Have you leveraged any of the Invoke APIs yet? Please share your stories with us here in the comments.

About Prosanta B.

Prosanta is a member of the BlackBerry Developer Relations team specializing in Web Development. Prosanta’s focus is on developing out the web platform and tools associated with web development while supporting the development efforts of a number of Independent Software Vendors. Prior to joining RIM, Prosanta had worked on numerous web portals for major multinational firms writing both front and backend code.

Join the conversation

Show comments Hide comments
+ -
blog comments powered by Disqus