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
BojanKogoj
Posts: 76
Registered: ‎01-08-2013
My Device: Z10 LE
My Carrier: SiMobil
Accepted Solution

Invocation; phone number to text or call

On button click I would like to give user an option what to do with that phone number: to call or send a text message

 

Button {
    text: "Call"
    id: phoneNumber
    onClicked: {
        invoke.trigger("bb.action.OPEN")
    }
}

attachedObjects: [
    Invocation {
        id: invoke
        query {
            mimeType: "text/plain"
            data: "+38640111222"
        }
    }
]

 I'm not sure what mimeType should be for this action, and if I went completely the wrong way.

Please use plain text.
BlackBerry Development Advisor
Kareem_ELSayed
Posts: 81
Registered: ‎09-09-2013
My Device: BlackBerry Z10
My Carrier: Etisalat UAE

Re: Invocation; phone number to text or call

[ Edited ]

Hello,

Please check this link:

https://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/phone.html


Thanks,
Kareem.

Kareem ELSayed | Application Development Consultant | Developer Relations | BlackBerry | Twitter:@kemobyte
Please use plain text.
BlackBerry Development Advisor
Kareem_ELSayed
Posts: 81
Registered: ‎09-09-2013
My Device: BlackBerry Z10
My Carrier: Etisalat UAE

Re: Invocation; phone number to text or call

Also as easy way to accomplish this:

 

 In your appUI.cpp / main, Include:

 

#include <bb/system/phone/Phone>
#include <bb/data/DataSource>

You would need to add LIBS += -lbbdata to the .Pro file.

 

Add these lines to register the system.phone and access it from QML:

 

    qmlRegisterType<bb::system::phone::Phone>("bb.system.phone", 1, 0, "Phone");
    DataSource::registerQmlTypes();

Then in the QML file: 

 

import bb.cascades 1.0
import bb.system.phone 1.0

Page {
    Container {
        horizontalAlignment: HorizontalAlignment.Fill
        verticalAlignment: VerticalAlignment.Fill
        Button {
            text: "Call Me!!"
            onClicked: {
                phone.initiateCellularCall("0038640111222");
            }
        }
    }
    attachedObjects: [
        Phone {
            id: phone
        }
    ]
}

 

Kareem ELSayed | Application Development Consultant | Developer Relations | BlackBerry | Twitter:@kemobyte
Please use plain text.
Developer
BojanKogoj
Posts: 76
Registered: ‎01-08-2013
My Device: Z10 LE
My Carrier: SiMobil

Re: Invocation; phone number to text or call

[ Edited ]

Well I thought it would ask me if I want to call or send SMS, but I suppose this should do.

 

However,

DataSource::registerQmlTypes();

 always gives me an error. Yes, I have both includes you provided, but even if i remove it, it still works with no errors

Please use plain text.
BlackBerry Development Advisor
Kareem_ELSayed
Posts: 81
Registered: ‎09-09-2013
My Device: BlackBerry Z10
My Carrier: Etisalat UAE

Re: Invocation; phone number to text or call

[ Edited ]

Hello,

Sorry I was copy pasting from old code :smileyhappy:. However to fix the error you can add this line:

using namespace bb::data;

 

or instead append the namespace to the same line 

bb::data&colon;:DataSource::registerQmlTypes();

 

Thanks,
Kareem.

Kareem ELSayed | Application Development Consultant | Developer Relations | BlackBerry | Twitter:@kemobyte
Please use plain text.
Developer
BojanKogoj
Posts: 76
Registered: ‎01-08-2013
My Device: Z10 LE
My Carrier: SiMobil

Re: Invocation; phone number to text or call

Yup yup thanks, that was an obvious one.

Please use plain text.