Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7860829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:27:18+00:00 2026-06-02T22:27:18+00:00

I need a sample application code for push integration in my blackberry application. I

  • 0

I need a sample application code for push integration in my blackberry application. I have registered my application for the push credentials and have received them.

please help,

Kind Regards,
Rupesh

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:27:19+00:00Added an answer on June 2, 2026 at 10:27 pm

    This is fully working push application code it may be help you for implement push notification.

    public class push_Main {
    
    /**
     * Entry point for this application
     * @param args Command line arguments (not used)
     */
    
    private static final String REGISTER_SUCCESSFUL = "rc=200";
    private static final String DEREGISTER_SUCCESSFUL = REGISTER_SUCCESSFUL;
    private static final String USER_ALREADY_SUBSCRIBED = "rc=10003";
    private static final String ALREADY_UNSUSCRIBED_BY_USER = "rc=10004";
    private static final String ALREADY_UNSUSCRIBED_BY_PROVIDER = "rc=10005";
    
    private static final String PUSH_PORT = "";  //push port
    private static final String BPAS_URL = "http://pushapi.eval.blackberry.com";
    private static final String APP_ID = "";   // add application id
    //  private static final String CONNECTION_SUFFIX = ";deviceside=false;ConnectionType=seekrit string";
    
    private static String URL = "http://:100"; // PORT 100 add your posh port.
    private static final int CHUNK_SIZE = 256;
    
    public static ListeningThread _listeningThread;
    public static StreamConnectionNotifier _notify;
    
    private static final long ID = 0x954a603c0dee81e0L;
    
    
    public push_Main() {
        // TODO Auto-generated constructor stub
    
        NotificationsManager.registerSource(ID, theSource, NotificationsConstants.IMPORTANT);
            if(_listeningThread==null)
            {
                System.out.println("msg on listening thread 1");        
                _listeningThread = new ListeningThread();
                System.out.println("msg on listening thread 2");
                _listeningThread.start();
                System.out.println("msg on listhning thread 3 ");
    
    
            } 
    
    
    }
    public static class ListeningThread extends Thread
    {
        private boolean _stop = false;
    
        /**
         * Stops the thread from listening.
         */
        private synchronized void stop()
        {
            _stop = true;
            try 
            {
                // Close the connection so the thread will return.
                _notify.close(); 
            } 
            catch (Exception e) 
            {      
    
            }          
        }
    
        /**
         * Listen for data from the HTTP url. After the data has been read, 
         * render the data onto the screen.
         * @see java.lang.Runnable#run()
         */
    
        public void run()
        {
    
            StreamConnection stream = null;
            InputStream input = null;
            MDSPushInputStream pushInputStream=null;
    
            while (!_stop)
            {
                try 
                {
    
                    // Synchronize here so that we don't end up creating a connection that is never closed.
                    synchronized(this)  
                    {
                        // Open the connection once (or re-open after an IOException),  so we don't end up 
                        // in a race condition, where a push is lost if it comes in before the connection 
                        // is open again. We open the url with a parameter that indicates that we should 
                        // always use MDS when attempting to connect.
                        System.out.println("\n\n msg connection 1");
                        _notify = (StreamConnectionNotifier)Connector.open(URL);
                        System.out.println("\n\n msg connection 2");
    
                    }
    
                    while (!_stop)
                    {
    
                        // NOTE: the following will block until data is received.
                        System.out.println("\n\n msg notify 1");
                        stream = _notify.acceptAndOpen();
                        System.out.println("\n\n msg 1 ");
    
                        try 
                        {
                            System.out.println("\n\n msg 2");
                            input = stream.openInputStream();
                            System.out.println("\n\n msg 3 ");
    
                            pushInputStream= new MDSPushInputStream((HttpServerConnection)stream, input);
    
                            System.out.println("\n\n msg 4");
                            // Extract the data from the input stream.
    
                            DataBuffer db = new DataBuffer();
    
                            byte[] data = new byte[CHUNK_SIZE];
                            int chunk = 0;
    
                            while ( -1 != (chunk = input.read(data)) )
                            {
                                db.write(data, 0, chunk);
                            }
    
                            updateMessage(data);
    
                            // This method is called to accept the push.
                            pushInputStream.accept();                          
    
                            data = db.getArray();
                        } 
                        catch (IOException e1) 
                        {
                            // A problem occurred with the input stream , however, the original 
                            // StreamConnectionNotifier is still valid.
                            //                          errorDialog(e1.toString());                   
                        }
                        finally
                        {
                            if ( input != null ) 
                            {
                                try 
                                {
                                    input.close();
                                } 
                                catch (IOException e2) 
                                {                  
    
                                }
                            }
    
                            if ( stream != null )
                            {
                                try 
                                {
                                    stream.close();
                                } 
                                catch (IOException e2) 
                                {                                    
                                }
                            }                                                 
                        }
                    }                  
                } 
                catch (IOException ioe)
                {
                    // Likely the stream was closed. Catches the exception thrown by 
                    // _notify.acceptAndOpen() when this program exits.
                    errorDialog(ioe.toString());        
                }
                finally
                {
                    /*
    
                    if ( _notify != null ) 
                    {
                        try 
                        {
                            _notify.close();
                            _notify = null;
                        } 
                        catch ( IOException e ) 
                        {          
    
                        }
                    }
    
                     */
    
                }
            }
        }
    }
    
    
    private static void updateMessage(final byte[] data)
    {
        System.out.println("\n\n msg 6");
    
        Application.getApplication().invokeLater(new Runnable() 
        {
            public void run() 
            {
                // Query the user to load the received message.
    
                //              Dialog.alert( new String(data));
    
    
                UiApplication.getUiApplication().invokeLater( new Runnable() {
                    public void run()
                    {
                        NotificationsManager.triggerImmediateEvent(ID, 0, null, null);
                        Dialog d = new Dialog( Dialog.D_OK, new String(data) ,0, null, Screen.DEFAULT_CLOSE);
                        //                      _dialogShowing = true;
                        UiApplication.getUiApplication().pushGlobalScreen( d, 10, UiApplication.GLOBAL_MODAL );
    
                        // Dialog is closed at this point, so we cancel the event.                                        
    
                    }
                } );
    
    
            }
    
        });
    } 
    
    public static void registerBpas() {
    
        /**
         * As the connection suffix is fixed I just use a Thread to call the connection code
         * 
         **/
    
        new Thread() {
            public void run() {
                try {
                    final String registerUrl = formRegisterRequest(BPAS_URL, APP_ID, null) + Conn.getConnectionParameters();
                    System.out.println("\n\n\n msg registerBPAS URL is:  "+ registerUrl);
                    HttpConnection httpConnection = (HttpConnection) Connector.open(registerUrl);
                    InputStream is = httpConnection.openInputStream();
                    String response = new String(IOUtilities.streamToBytes(is));
                    System.out.println("\n\n\n\n\n\n msg RESPOSE CODE :    " + response);
                    close(httpConnection, is, null);
                    String nextUrl = formRegisterRequest(BPAS_URL, APP_ID, response) + Conn.getConnectionParameters();
                    System.out.println("\n\n\n\n\n\n msg nextUrl :    " + nextUrl);
                    HttpConnection nextHttpConnection = (HttpConnection) Connector.open(nextUrl);
                    InputStream nextInputStream = nextHttpConnection.openInputStream();
                    response = new String(IOUtilities.streamToBytes(nextInputStream));
                    System.out.println("\n\n\n\n\n\n msg RESPOSE CODE 1:    " + response);
                    close(nextHttpConnection, is, null);
                    if (REGISTER_SUCCESSFUL.equals(response) || USER_ALREADY_SUBSCRIBED.equals(response)) {
                        System.out.println("msg Registered successfully for BIS push");
                    } else {
                        System.out.println("msg BPAS rejected registration");
                    }
                } catch (final IOException e) {
    
                    System.out.println("msg IOException on register() " + e + " " + e.getMessage());
                }
            }
        }.start();
    }
    
    public static void close(Connection conn, InputStream is, OutputStream os) {
        if (os != null) {
            try {
                os.close();
            } catch (IOException e) {
            }
        }
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
            }
        }
        if (conn != null) {
            try {
                conn.close();
            } catch (IOException e) {
            }
        }
    }
    
    public static void errorDialog(final String message)
    {
        UiApplication.getUiApplication().invokeLater(new Runnable()
        {
            public void run()
            {
                Dialog.alert(message);
            } 
        });
    }
    
    private static String formRegisterRequest(String bpasUrl, String appId, String token) {
        StringBuffer sb = new StringBuffer(bpasUrl);
        sb.append("/mss/PD_subReg?");
        sb.append("serviceid=").append(appId);
        sb.append("&osversion=").append(DeviceInfo.getSoftwareVersion());
        sb.append("&model=").append(DeviceInfo.getDeviceName());
        if (token != null && token.length() > 0) {
            sb.append("&").append(token);
        }
        return sb.toString();
    }
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a sample C# (console application) code witch connects to an SQL Server
i have done developed a sample application with the help of tutorials posted on
I'm developing an application with the help of sample code from the WWDC 2010
Do you guys came across any sample application (i need source code of the
I have a little paint application which was based on the GLPaint sample code.
I have a relatively simple application which I need to make native Mac OSX
I have a simple application in which I need to let the user select
I have googled some time now trying to find a good sample application that
I create a sample Live wallpaper application, My requirement is, the Live-wallpaper have a
I am developing an application for android v1.5, I need to use Push messaging

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.