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

Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus
Accepted Solution

Are your customers having Permission issues?

[ Edited ]

I've was experiencing customers turning of vital permissions by accident during the first installation.  So I have come up with a very simple solution and decided to share the code.



namespace system
    	class InvokeManager;
      Q_INVOKABLE void permissions();
public slots:
      Q_INVOKABLE void processInvokeReply();


#include <bb/system/InvokeRequest>
#include <bb/system/InvokeManager>
#include <bb/system/InvokeTargetReply>
using namespace bb::system;

setup a context property after opening your main.qml

QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("cpp", this); //used to call permissions() from qml

create the function

void ApplicationUI::permissions()
	InvokeRequest request;

	    // Setup the request properties according to the current configuration

	    // Start the invocation
	    const InvokeReply *reply = m_invokeManager->invoke(request);
	    if (reply) {
	        // Ensure that processInvokeReply() is called when the invocation has finished
	        QObject::connect(reply, SIGNAL(finished()), this, SLOT(processInvokeReply()));
	    } else {
	        //m_errorMessage = tr("Invoke Failed! InvokeReply is empty.");
	        //emit errorMessageChanged();

create a function to process the reply & delete the invocation so it can be used again later

void ApplicationUI::processInvokeReply() {
	InvokeReply *reply = qobject_cast<InvokeReply*>(sender());
	    // Delete the reply later on


In qml simply attach a call to run the function and you're all set


Container {
         horizontalAlignment: HorizontalAlignment.Fill
         Label {
              text: "Adjust Permissions"
              textStyle.base: SystemDefaults.TextStyles.BigText
              horizontalAlignment: HorizontalAlignment.Center
         onTouch: {
              if (event.isUp()){
                   console.log("Adjsut Permissions")


Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

Re: Are your customers having Permission issues?

Forgot to mention you'll need to add to the .pro file



LIBS += -lbb -lbbsystem

 If you want to try it out in live action just download Spy Cam Extreme and scroll to the bottom of the help page =)