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
marcossit
Posts: 176
Registered: ‎07-19-2012
My Device: Z10 Limited Edition and Dev Alpha C

Help integration my app in BBM 10

I found this information but just not my app connects to the BBM

 

https://developer.blackberry.com/cascades/documentation/device_platform/bbm/how_connect_app_bbmsp_ca...

 

create a hpp name RegistrationHandler.hpp

 

#include "RegistrationHandler.hpp"
#include <bb/platform/bbm/RegistrationState>
#include <bb/platform/bbm/Context>
#include <bb/cascades/QmlDocument>
#include "Global.hpp"

RegistrationHandler::RegistrationHandler()
{
  // Create the UI for the registration page and its components.
  QmlDocument* qmlContent = QmlDocument::create("asset:///registration.qml");
  if (qmlContent) {
    Control* content = qmlContent->createRootObject<Control>();
    this->setContent(content);
  }

  // Console Setup -- link BbmspBpsEventHandler to registrationCallback().
  m_statusText = this->findChild<TextArea*>("statusText");

  // Retrieve the button
  m_continueButton = this->findChild<Button*>("continueButton");

  // Connect the callback for the button.
  QObject::connect(m_continueButton,
         SIGNAL(clicked()),
         this,
         SLOT(continueToMainAppScreen()));

  //TODO:  Define your own UUID here.
  //You can generate one here: http://www.guidgenerator.com/
  m_uuid = QString::fromUtf8("14783db6-6871-4013-8048-2c77bf2441bd");
  // Your UUID goes here

  this->appRegister(); // Attempt to register the application
}

// Application registration
void RegistrationHandler::appRegister()
{
  qDebug() << "entering appRegister -> " << m_uuid;
  qDebug() << "before new Context";
  m_context = new bb::platform::bbm::Context(QUuid(m_uuid));
  Global::instance()->setContext(m_context);
  QObject::connect(m_context, SIGNAL(registrationStateUpdated(
                                     bb::platform::bbm::RegistrationState::Type)),
            this, SLOT(registrationStatus(
                       bb::platform::bbm::RegistrationState::Type)));
  qDebug() << "after new Context and connect";
  m_context->requestRegisterApplication();
  qDebug() << "registered -> " << m_uuid;
}

// Retrieve the registration status
void RegistrationHandler::checkRegistrationAccess(){
    bb::platform::bbm::RegistrationState::Type status =
                                    bb::platform::bbm::RegistrationState::Unknown;
    if (Global::instance()->getContext()) {
        status = Global::instance()->getContext()->registrationState();
    }
    registrationStatus(status);
}

// Handle the registration status
void RegistrationHandler::registrationStatus(
                            bb::platform::bbm::RegistrationState::Type state) {
    qDebug() << "Registration Status received";

  switch(state){
    case bb::platform::bbm::RegistrationState::Unregistered:
        qDebug() << ("Unregistered");
      this->registrationFailed();
      break;

    case bb::platform::bbm::RegistrationState::Unknown:
        qDebug() << ("Access failed: unknown reason");
      this->registrationFailed();
      break;

    case bb::platform::bbm::RegistrationState::Allowed:
      qDebug() << "RegistrationPage::registrationStatus Access allowed";
      m_statusText->setText("BBM SP registration succeeded.  Press Continue.");
      m_continueButton->setVisible(true);
      break;

    case bb::platform::bbm::RegistrationState::Pending:
      qDebug() << "RegistrationState::Pending";
      this->registrationFailed();
      break;

    case bb::platform::bbm::RegistrationState::BlockedByUser:
        qDebug() << ("Access failed: blocked by user");
      this->registrationFailed();
      break;

    case bb::platform::bbm::RegistrationState::BlockedByRIM:
        qDebug() << ("Access failed: blocked by RIM"  );
      this->registrationFailed();
      break;

    case bb::platform::bbm::RegistrationState::NoDataConnection:
        qDebug() << ("Access failed: no data coverage");
      this->registrationFailed();
      break;

    case bb::platform::bbm::RegistrationState::UnexpectedError:
        qDebug() << ("Access failed: unexpected error");
      this->registrationFailed();
      break;

    case bb::platform::bbm::RegistrationState::InvalidUuid:
        qDebug() << ("Access failed: invalid UUID");
      this->registrationFailed();
      break;

    case bb::platform::bbm::RegistrationState::TemporaryError:
        qDebug() << ("Access failed: temporary error");
      this->registrationFailed();
      break;

    case bb::platform::bbm::RegistrationState::CancelledByUser:
      qDebug() << ("Access cancelled by user");
      this->registrationFailed();
      break;

    case bb::platform::bbm::RegistrationState::MaxDownloadsReached:
        qDebug() << ("Access failed: max downloads reached");
      this->registrationFailed();
      break;

    case bb::platform::bbm::RegistrationState::MaxAppsReached:
        qDebug() << ("Access failed: max apps reached");
      this->registrationFailed();
      break;

    case bb::platform::bbm::RegistrationState::Expired:
        qDebug() << ("Access failed: access expired");
      this->registrationFailed();
      break;

    default:
        qDebug() << ("Access failed: other errors");
      this->registrationFailed();
      break;
    }
}

// Handle registration failure
void RegistrationHandler::registrationFailed()
{
    //A generic error message is provided here.
    //You can provide a different error message for each failure code to instruct
    //the user on how to continue.
    m_statusText->setText("BBM SP registration failed. Registration is required to connect with BlackBerry Messenger. Please restart the application to try again.");
    m_continueButton->setVisible(false);
}

// Handle successful registration
void RegistrationHandler::continueToMainAppScreen()
{
    //TODO: Display your application's main screen here
}

 create a qml name registration.qml

 

import bb.cascades 1.0
 
Container {
    layout: StackLayout {
    }
    background: Color.create("#c6f66f")
    Container {
        horizontalAlignment: HorizontalAlignment.Center
        TextArea {
            id: statusText
            objectName: "statusText"
            text: "Please wait while the application registers with BBM SP."
            editable: false
        }
        Button {
            id: continueButton
            objectName: "continueButton"
            visible: false
            text: "Continue"
            layoutProperties: StackLayoutProperties {
            }
            horizontalAlignment: HorizontalAlignment.Center
            onClicked: {
                nextLabel.visible = true;
            }
        }
        TextArea {
            id: nextLabel
            text: "Now you would display your application's main screen."
            visible: false
            backgroundVisible: false
            textStyle {
                color: Color.Black
                fontWeight: FontWeight.Bold
            }
        }
    }
}

 good from the main registration.qml invoked to connect but nothing happens. not connected or do anything that may be the solution to integrate the BBM, there is no example of this to see it better?

 

I gave him permission to BBM and add the library

 

Help Meee Please.

 

Thanks

 


Follow me in Twitter:

@Marcossit

BBM Channel:

MarcossitDev: C0002C366  

DeviceSuite For BlackBerry 10:

Link to Download DeviceSuite:

Support was successful? Accept as Solution and click on:


Developer
bbquincar
Posts: 304
Registered: ‎08-14-2012
My Device: PlayBook, Z10, Dev C

Re: Help integration my app in BBM 10

did you do the config part first

 

Configure your project in the QNX Momentics IDE

Add the BBM Social Platform library and set the permissions for the bbmsp APIs.

  1. In the Package Explorer view, right-click your project name.
  2. Click Configure > Add library.
  3. Select Standard BlackBerry platform library.
  4. Click Next.
  5. Select BlackBerry Social Platform BBM - libbbplatformbbm.
  6. Click Next. Click Finish.
  7. Expand your project.
  8. Open the bar-descriptor.xml file for your project.
  9. On the Application tab, in the Permissions section, select BlackBerry Messenger(bbm_connect).
  10. Save your project.

i followed the same steps but can figure out why it wont work either

BlackBerry 10 game reviews for the unknown, small and indie developers. Little games with big dreams. VeryBerryGames.com | Follow @VeryBerryGames | TwoCasualCoders.com | never casual on quality
Developer
greenback
Posts: 535
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: Help integration my app in BBM 10

I was going through the docs. RegistrationHandler.cpp imports 

#include "Global.hpp"

Where is this file? 

I am only able to get the security prompt asking me to approve BBM access when I go through the BBM docs tutorial.

 

BUMP

Developer
marcossit
Posts: 176
Registered: ‎07-19-2012
My Device: Z10 Limited Edition and Dev Alpha C

Re: Help integration my app in BBM 10

I also think I have that doubt that the statute of integration is slightly incomplete or confusing, alguin hopefully help us.


Follow me in Twitter:

@Marcossit

BBM Channel:

MarcossitDev: C0002C366  

DeviceSuite For BlackBerry 10:

Link to Download DeviceSuite:

Support was successful? Accept as Solution and click on:


Developer
bbquincar
Posts: 304
Registered: ‎08-14-2012
My Device: PlayBook, Z10, Dev C

Re: Help integration my app in BBM 10

[ Edited ]

isnt

#include "Global.hpp"

 just the name of there file i have mine as 

#include "alphab.hpp"

the first file RegistrationHandler is suppose to be hpp/cpp im confused now @greenback you metioned cpp imports

BlackBerry 10 game reviews for the unknown, small and indie developers. Little games with big dreams. VeryBerryGames.com | Follow @VeryBerryGames | TwoCasualCoders.com | never casual on quality
Contributor
ejup2009
Posts: 20
Registered: ‎05-18-2010
My Device: BOLD 9900

Re: Help integration my app in BBM 10

U changed this name and desaapear the bug but now i runm the app and doesn't make anything, only the first time appear me an instruccion say me that connecting but now ... pUFFF .. Is it normal that?
Enviado de mi BlackBerry Bold 9900

Ejup2009_Dev
BlackBerry Development Advisor
MSohm
Posts: 14,757
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Help integration my app in BBM 10

I've attached a sample project that implements BBM registration.  This sample is what the docs were based off of.

 

This sample, along with a few others that showcase BBM features will be posted to the BlackBerry Github site very soon.

 

https://github.com/blackberry

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
bbquincar
Posts: 304
Registered: ‎08-14-2012
My Device: PlayBook, Z10, Dev C

Re: Help integration my app in BBM 10

[ Edited ]

So iv been able to get my bbm sp registration page up and running but i dont know enough C++ to make the countinue button go to my main.qml page please help. just relook at the code can this be done from qml. im sure its something i just forgot.

BlackBerry 10 game reviews for the unknown, small and indie developers. Little games with big dreams. VeryBerryGames.com | Follow @VeryBerryGames | TwoCasualCoders.com | never casual on quality
BlackBerry Development Advisor
MSohm
Posts: 14,757
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Help integration my app in BBM 10

More BBM samples have been posted in our github site here:  https://github.com/blackberry/Cascades-Community-Samples

 

Have a look at some of the other BBMQt samples for examples that move on to another screen.

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
bbquincar
Posts: 304
Registered: ‎08-14-2012
My Device: PlayBook, Z10, Dev C

Re: Help integration my app in BBM 10

[ Edited ]

I took a look at the all last night and really not sure what im looking for.

Im trying to figure out if moving to the next screen is done from the qml side with simple push function;

or if i need to lookup a C++ function in which case i wouldnt know what to look for.

 

Ok I started over and it seem the code has been changed im getting errros in this section of my RegistrationHandler.cpp - i cant figure this out.

 

void RegistrationHandler::appRegister()
{
  qDebug() << "entering appRegister -> " << m_uuid;
  qDebug() << "before new Context";
  m_context = new bb::platform::bbm::Context(QUuid(m_uuid));
  Global::instance()->setContext(m_context);
  QObject::connect(m_context, SIGNAL(registrationStateUpdated(bb::platform::bbm::RegistrationState::Type)),
  			this, SLOT(registrationStatus(bb::platform::bbm::RegistrationState::Type)));
  qDebug() << "after new Context and connect";
  m_context->requestRegisterApplication();
  qDebug() << "registered -> " << m_uuid;
}

void RegistrationHandler::checkRegistrationAccess(){
	bb::platform::bbm::RegistrationState::Type status = bb::platform::bbm::RegistrationState::Unknown;
	if (Global::instance()->getContext()) {
		status = Global::instance()->getContext()->registrationState();
	}
	registrationStatus(status);
}

 

BlackBerry 10 game reviews for the unknown, small and indie developers. Little games with big dreams. VeryBerryGames.com | Follow @VeryBerryGames | TwoCasualCoders.com | never casual on quality