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
Regular Contributor
Posts: 77
Registered: ‎01-27-2010
My Device: Dev Alpha
Accepted Solution

Is there any way to get Device PIN ?

Hi, everyone

 

Is there any way to get a device PIN programmatically in Cascades C++? I search this forum and find this thread is talk about that but its answer can't help me. My code is here.

 

TestGetPin::TestGetPin(bb::cascades::Application *app)
: QObject(app)
{
    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

    // create root object for the UI
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    // set created root object as a scene
    app->setScene(root);

    getDevicePIN();
}

QString TestGetPin::getDevicePIN()
{
    QString pin;
    deviceinfo_identifying_details_t *deviceDetails;
    if(deviceinfo_get_identifying_details(&deviceDetails) == BPS_SUCCESS) {
        int pinValue = deviceinfo_identifying_details_get_pin(deviceDetails);
        pin = QString::number(pinValue, 16);
        deviceinfo_free_identifying_details(&deviceDetails);
    }
    qDebug() << "pin: "+pin;
    return pin;
}

 

 But console print a blank value (only "pin: "). :smileysad:

If anyone know how to get a device PIN completely. Could you post your full code sample, please? I'll be thankful for your kindness. :smileyhappy:

Maz

Developer
Posts: 216
Registered: ‎09-18-2009
My Device: Z10

Re: Is there any way to get Device PIN ?

[ Edited ]
deviceinfo_identifying_details_t** deviceinfo_identifying_details = new deviceinfo_identifying_details_t*;
int deviceinfo_get_identifying_details_result = deviceinfo_get_identifying_details(deviceinfo_identifying_details);
if (deviceinfo_get_identifying_details_result != BPS_SUCCESS) {
    deviceinfo_free_identifying_details(deviceinfo_identifying_details);
    delete deviceinfo_identifying_details;
    return;
}
int pin = deviceinfo_identifying_details_get_pin(*deviceinfo_identifying_details);
QString pinHex = QString::number(pin, 16);
qDebug() << "pinHex: " << pinHex;

 

This code should do it :-)

Regular Contributor
Posts: 77
Registered: ‎01-27-2010
My Device: Dev Alpha

Re: Is there any way to get Device PIN ?

Thank you very much, oliver_kranz !!  Your code is work for me .. and my old code is work too! Because I forget to set a Device Identifying permission of bar-descriptor.xml file.  :Tt2:

Maz

 

Developer
Posts: 115
Registered: ‎10-22-2012
My Device: Developer

Re: Is there any way to get Device PIN ?

Cascades have built in function to get Device PIN

https://developer.blackberry.com/cascades/reference/bb__device__hardwareinfo.html#function-pin



Like my answer if it's helpful. Mark as answer if it help you solve the problem.