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
Developer
Posts: 216
Registered: ‎09-18-2009
My Device: Z10
My Carrier: O2
Accepted Solution

Check permissions

We need access to restricted functionality on the device. The device permissions the application requires can be specified in the BAR application descriptor file.

 

Is there a way to check if permissions are denied or allowed by the user?

 

The API provides a class ApplicationPermissions.

 

#include <bb/platform/bbm/ApplicationPermissions>
 
But it can only be used to check BBM permissions.
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Check permissions

There's no direct, unified API for this (yet). For now, attempt to perform one of the restricted actions and catch any exceptions that are raised.

For example, if you try to do a directory listing on the shared/ subfolders and don't have access_shared granted by the user, you should get a permission violation.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 216
Registered: ‎09-18-2009
My Device: Z10
My Carrier: O2

Re: Check permissions

Okay, thanks.

 

Hopefully, the API comes with the next release of the Native SDK. Unfortunately, the exceptions which will be thrown are not documented. So, there is no known exception to react on. For instance, if a network request fails because of missing permissions we want to show a popup. Showing this popup always when an exception is thrown can be wrong.

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Check permissions

At least so far, I've never seen a permission that prevents basic network access. In spite of the existence of access_internet and the docs, I don't think it's ever been required yet. Maybe it was added recently... i haven't tested in a couple of versions.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!