Search code examples
blackberrybb-messenger

how to send message in Blackberry messenger using BBM PIN via Application


i dont have experience in BBM and in my application , one requirement is that . .there in one Buttonfield. when i click on that Button one PopupScreen open .PopupScreen have three field . one TextField second "SendButton" third "Canclebutton" .

i have to enter BBM PIN in TextField and when i click on SendButton .. i have one static massage which will be send to other user (PIN user).

how to implement this ? is there any sdk to implement this ?

can we check this in Simulator ?


Solution

  • You dont need to use BBM SDK to send a pin message to another user from your application. BB pin is not just limited to BBM. It is a unique identifier for your Blackberry which you can use to send messages using Pin. You can also use your pin along with BBM to send messages in BBM. If you need to enter the pin in a textfield, and send a pre-filled message, you dont need to use BBM. You can use Use the following method to send a pin message

    public static void sendPinMessage(String address,String body)
    {
     Store store = Session.getDefaultInstance().getStore();
    
    //retrieve the sent folder
    Folder[] folders = store.list(Folder.SENT);
    Folder sentfolder = folders[0];
    
    //create a new message and store it in the sent folder
    Message msg = new Message(sentfolder);
    PINAddress recipients[] = new PINAddress[1];
    
    try{
        //create a pin address with destination address 
        recipients[0]= new PINAddress(address,"My app");
    }
    
    catch (AddressException ae)
    {
        Log.Error(ae,"Check address");
    }
    
    try{
        //add the recipient list to the message
        msg.addRecipients(Message.RecipientType.TO, recipients);
    
    //set a subject for the message
    
            msg.setSubject("Subject");
    
        //sets the body of the message
        msg.setContent(body);
    
        //send the message
        Transport.send(msg);
    }
    
    catch (MessagingException me)
    {
        Log.Error(me,"Message excpetion in sending pin");
    }
    }