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
pepe_ugalde
Posts: 64
Registered: ‎09-10-2012
My Device: Developer
My Carrier: AMX
Accepted Solution

How to check permissions

Hi guys

 

I'm developing an app and I'm facing some problems.

 

The app needs to read SIM data to display info depending on the SIM's country. The first thing it does after opening is read the SIM; if no SIM is detected an error is displayed, if it can be read the app displays a list. I'll go into more detail.

 

I have added in the bar-descriptor the "read_cellular_data" permission. When the app opens for the first time, it asks the user for permission, this is normal. After the user presses accept, the screen remains black. Minimizing the app only makes the splash screen visible. You can only close the app.

After opening the app for the second+ time, the app works normally.

 

Also, when I ask for the SIM state using "SimCardInfo().state();" I get "NotDetected" if there is no SIM and if the app has no permission. I'd like to know how to make a difference between those 2.

 

My theory is that I need to check for permission, but i cannot find any info about permissions. All I found is the following pages:

 

The App permissions page, which does not describe how to check for permissions

and this forum post, which is not for BB10

 

Any help/hints/pointers would be greatly appreciated.

Pepe

 

Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: How to check permissions

I don't think this is right forum to ask.

Please use plain text.
Developer
pepe_ugalde
Posts: 64
Registered: ‎09-10-2012
My Device: Developer
My Carrier: AMX

Re: How to check permissions

... but it's a BB10 native related question.

Which would be the right forum?

Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: How to check permissions

I am not aware of function SimCardInfo() in Native environment. Is there one?

Please use plain text.
Developer
pepe_ugalde
Posts: 64
Registered: ‎09-10-2012
My Device: Developer
My Carrier: AMX

Re: How to check permissions

Yes, it's here:

https://developer.blackberry.com/cascades/reference/bb__device__simcardinfo.html

 

But I can't find any info on checking permissions.

Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: How to check permissions

Wow.. sorry missed that. Though can't answer your question now. -(

Please use plain text.
Developer
oliver_kranz
Posts: 216
Registered: ‎09-18-2009
My Device: Z10
My Carrier: O2

Re: How to check permissions

There is no permission read_cellular_data. It is not on the App permissions page you posted. And it is not in the bar-descriptor.xml.

Please use plain text.
Developer
pepe_ugalde
Posts: 64
Registered: ‎09-10-2012
My Device: Developer
My Carrier: AMX

Re: How to check permissions

I've seen that some permissions are not documented (can´t remember right now another example).

But in the SimCardInfo.hpp, you can find this:

 

/*!
     * @brief Retrieves the unique identifier for the country where the SIM card's home network 
     * is located.
     *
     * @details The mobile country code (MCC) is composed of 3 or 4 decimal digits. For further 
     * details about the structure of the MCC, see ITU-T recommendation E.212.
     *
     * @return The country code of the SIM card's home network encoded as a string or an empty 
     * string if the caller does not have sufficient permission or the SIM card's state is not 
     * @c SimCardState::Ready.
     *
     * @permissions The application must have the @c read_cellular_data permission to access this method.
     *
     */
    QString mobileCountryCode() const;

 

The app does ask for permission when first opened, and without it, I cannot read the SIM, so the permission is functional.

 

I was told through e-mail by a Developer Evangelist that for now there is no way to check/modify permissions.

 

My problem was that the app attempted to read SIM data as it opened, while the permission was asked only on the first time the app was opened, and once you accepted/rejected, the app would stay on the splash screen.


My workaround was to present a Welcome screen only the first time the app is opened, so no SIM data would be read while the permission is asked.

 

Cheers!

Pepe

Please use plain text.
Developer
oliver_kranz
Posts: 216
Registered: ‎09-18-2009
My Device: Z10
My Carrier: O2

Re: How to check permissions

That is interesting. It seems that the documentation of the source code differs from the online API documentation. In the online documentation the permission value is not mentioned.

 

We also want to check permissions because our app will not work if permissions are denied. Hopefully, this feature comes with one of the next releases of the SDK.

Please use plain text.
Developer
pepe_ugalde
Posts: 64
Registered: ‎09-10-2012
My Device: Developer
My Carrier: AMX

Re: How to check permissions

Supposedly, the new SDK will be out today.

 

They are still working on those APIs, so I think I'll ask the user which country they are in instead of reading the SIM :/

 

Too bad, lets wait for the new SDK, then.

Please use plain text.