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: 148
Registered: ‎04-08-2013
My Device: Blackberry 10

How to check if Target to communicate via social invocation is installed in the device

[ Edited ]

I am using Social invocation to post Message on Facebook from my App. Post works fine.

 

Issue:

 

My problem is when the Facebook app is not installed in the device no alert to the user is given while user tries to post on Facebook.

 

My Question:

Is there any way to check whether the app(The target for the social invocation) is installed in the device or not.So that I can alert the user to install the app.

Posts: 88,021
Likes: 23,483
Solutions: 6,061
Registered: ‎04-01-2008
My Device: Passport • Z30 • Z10 • Torch9850 • Playbook
My Carrier: Verizon

Re: How to check if Target to communicate via social invocation is installed in the device

Are you trying to develop an applicaiton for BlackBerry10?

 

If so, we'll ask a moderator to move this thread to the proper developer section of the forum.




1. If any post helps you please click the Like Button below the post(s) that helped you.
2. Please resolve your thread by marking the post "Solution?" which solved it for you!
3. Install free BlackBerry Protect today for backups of contacts and data.
4. Guide to Unlocking your BlackBerry & Unlock Codes


Join our BBM Channels (Beta)
BlackBerry Support Forums Channel
PIN: C0001B7B4   Display/Scan Bar Code
Knowledge Base Updates
PIN: C0005A9AA   Display/Scan Bar Code
Developer
Posts: 148
Registered: ‎04-08-2013
My Device: Blackberry 10

Re: How to check if Target to communicate via social invocation is installed in the device

Yes I am trying to impement this on BB z10. 

Posts: 88,021
Likes: 23,483
Solutions: 6,061
Registered: ‎04-01-2008
My Device: Passport • Z30 • Z10 • Torch9850 • Playbook
My Carrier: Verizon

Re: How to check if Target to communicate via social invocation is installed in the device

As a developer, you should be aware there is a dedicated section of this forum for developers to discuss, seek assistance and feed back on their apps. At the top of this forum page, see the "Developer Forums" link.




1. If any post helps you please click the Like Button below the post(s) that helped you.
2. Please resolve your thread by marking the post "Solution?" which solved it for you!
3. Install free BlackBerry Protect today for backups of contacts and data.
4. Guide to Unlocking your BlackBerry & Unlock Codes


Join our BBM Channels (Beta)
BlackBerry Support Forums Channel
PIN: C0001B7B4   Display/Scan Bar Code
Knowledge Base Updates
PIN: C0005A9AA   Display/Scan Bar Code
BlackBerry Development Advisor
Posts: 14,947
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: How to check if Target to communicate via social invocation is installed in the device

Have a look at the Target Discovery section of the Sending Invocation documentation.  You could use that to query if the Facebook application is available to accept invocation requests.  If it's not, it's not installed.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 148
Registered: ‎04-08-2013
My Device: Blackberry 10

Re: How to check if Target to communicate via social invocation is installed in the device

Thanks Sohm for you reply.

 

What I tried

void SocialInvocation::shareOnFacebook(QString dataToPost)
{

    InvokeRequest request;
    request.setTarget("Facebook");
    request.setAction("bb.action.SHARE");
    request.setMimeType("text/plain");
    request.setData(dataToPost.toAscii());
    InvokeTargetReply *reply = m_invokeManager->invoke(request);
    reply->setParent(this);
    // Listen for the invoke response.

    // If any Q_ASSERT statement(s) indicate that the slot failed to connect to
    // the signal, make sure you know exactly why this has happened. This is not
    // normal, and will cause your app to stop working!!
    bool connectResult;

    // Since the variable is not used in the app, this is added to avoid a
    // compiler warning.
    Q_UNUSED(connectResult);

    connectResult = QObject::connect(reply, SIGNAL(finished()), this, SLOT(onInvokeResult()));

    // This is only available in Debug builds.
    Q_ASSERT(connectResult);

    // Store reply somewhere, so you can
    // access it when onInvokeResult fires.
    _invokeTargetReply = reply;

}

 //code to check whether the app is installed or not
void SocialInvocation::onInvokeResult()
{
    // Check for errors
    switch (_invokeTargetReply->error()) {
        // Invocation could not find the target
        // did we use the right target ID?
        case InvokeReplyError::NoTarget: {
            qDebug() << "invokeFinished(): Error: no target" << endl;
            alert("Please install the native Twitter and Facebook Apps to continue");
            break;
        }
            // There was a problem with the invoke request
            // did we set all the values correctly?
        case InvokeReplyError::BadRequest: {
            qDebug() << "invokeFinished(): Error: bad request" << endl;
            break;
        }
            // Something went completely
            // wrong inside the invocation request
            // Find an alternate route :(
        case InvokeReplyError::Internal: {
            qDebug() << "invokeFinished(): Error: internal" << endl;
            break;
        }
            //Message received if the invoke request is successful
        default:
            qDebug() << "invokeFinished(): Invoke Succeeded" << endl;
            break;
    }

    // A little house keeping never hurts...
    delete _invokeTargetReply;
}

 My issue is:

 

  When I try this code on 10.0 simulator it works fine.It enters to 

case InvokeReplyError::NoTarget: {

 But when I try this on my 10.2 BBz10 device then its not at all working.It is entering to 

 default:
            qDebug() << "invokeFinished(): Invoke Succeeded" << endl;
            break;

 Can nay one please please help me.I am stuked here.

 

 

Developer
Posts: 148
Registered: ‎04-08-2013
My Device: Blackberry 10

Re: How to check if Target to communicate via social invocation is installed in the device

Any one please help me. I am stucked here. Any ideas

Developer
Posts: 93
Registered: ‎10-19-2012
My Device: Playbook, BB10DevAlphaB

Re: How to check if Target to communicate via social invocation is installed in the device

Have you tried the "Target discovery" example ?
Developer
Posts: 148
Registered: ‎04-08-2013
My Device: Blackberry 10

Re: How to check if Target to communicate via social invocation is installed in the device

Is there any sample available for this.Can you plz post the url or some codes for the same.

Developer
Posts: 93
Registered: ‎10-19-2012
My Device: Playbook, BB10DevAlphaB

Re: How to check if Target to communicate via social invocation is installed in the device

It is on the same page that MSohm already mentioned, but here goes https://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/sending_in...